Open source personal finance application
update useTouchClose and all modals
ilkomefed532a7b5a0
diff --git a/assets/stylus/common/animations.styl b/assets/stylus/common/animations.stylindex 44c9a97d..2df48d0e 100644--- a/assets/stylus/common/animations.styl+++ b/assets/stylus/common/animations.styl@@ -6,12 +6,10 @@ $transition-style = cubic-bezier(.17, .04, .03, 1)opacity 1transition all 150ms ease-out- &._slow- transition all 600ms ease-&-enter&-leave-toopacity 0+ transition all 150ms ease-out.fadeInSlow&-enter-active@@ -32,14 +30,14 @@ $transition-style = cubic-bezier(.17, .04, .03, 1)@media $media-phonetransform translate(0, 0)- transition opacity 200ms ease-out, transform 250ms ease-out+ transition opacity 100ms ease-out, transform 150ms $transition-style@media $media-laptoptransform translate(0, 0)&-enteropacity 0- transition opacity 200ms ease-out, transform 250ms ease-out+ transition opacity 100ms ease-out, transform 150ms $transition-style@media $media-phonetransform translate(0, 10px)@@ -50,15 +48,14 @@ $transition-style = cubic-bezier(.17, .04, .03, 1)&-leave-active&-leave-toopacity 0- transition opacity 200ms ease-out, transform 250ms ease-out- // transition none+ transition opacity 100ms ease-out, transform 150ms $transition-style.slide2&-enter-active&-leave-activeopacity 1transform translate(0, 0)- transition opacity 100ms ease-out, transform 150ms ease-out+ transition opacity 100ms ease-out, transform 150ms $transition-style&-enter&-leave-todiff --git a/components/app/UpdateAppModal.vue b/components/app/UpdateAppModal.vueindex d1758151..7059afaf 100644--- a/components/app/UpdateAppModal.vue+++ b/components/app/UpdateAppModal.vue@@ -1,11 +1,6 @@<script>export default {- name: 'UpdateAppModal',-- setup () {- const reload = () => { location.reload() }- return { reload }- }+ name: 'UpdateAppModal'}</script>@@ -21,7 +16,7 @@ ModalBottom(Button(className="_blue _text-center":title="$t('base.ok')"- @onClick="reload"+ @onClick="$emit('onClose')")</template>diff --git a/components/base/modal/useTouchClose.ts b/components/base/modal/useTouchClose.tsnew file mode 100644index 00000000..9862ba04--- /dev/null+++ b/components/base/modal/useTouchClose.ts@@ -0,0 +1,187 @@+import { onUnmounted } from '@nuxtjs/composition-api'++export default function useOnTouch () {+ let isDragging = true+ let isDrugByHandler = false+ let initialY = 0+ let currentY = 0++ let config = {+ dragOffset: 16,+ whaitForScrollClassName: 'waitForScroll',+ doNotTouchClassName: 'doNotCloseModal',+ animClassName: '_anim'+ }++ let container: (null | any) = null+ let overflow: (null | any) = null+ let wrap: (null | any) = null+ let content: (null | any) = null+ let onClose: (null | any) = null+ let handler: (null | any) = null+ let isInit: Boolean = false++ /**+ * Init+ * @param props+ */+ function initTouchModal (props: any): void {+ container = props.container+ overflow = props.overflow+ wrap = props.wrap+ content = props.content+ onClose = props.onClose+ handler = props.handler++ if (props.config) {+ config = {+ ...config,+ ...props.config.value+ }+ }++ if (!isInit) {+ isInit = true+ container.value.addEventListener('touchstart', onDragStart)+ container.value.addEventListener('touchmove', onDragging)+ container.value.addEventListener('touchend', onDragEnd)+ container.value.addEventListener('mouseup', onDragEnd)+ }+ }++ /**+ * Translate+ */+ function setTranslate (): void {+ if (!wrap.value) { return }+ const offset = isDrugByHandler ? 0 : config.dragOffset++ if (currentY === 0) {+ wrap.value.style.transform = ''+ overflow.value.style.opacity = ''+ }+ else if (currentY > offset) {+ const containerHeight = container.value.clientHeight+ const diff = (containerHeight - currentY) / (containerHeight / 100)+ const diffTrunc = Math.trunc(diff)+ const opacity = diffTrunc === 100 ? 1 : diffTrunc >= 10 ? `0.${diffTrunc}` : `0.0${diffTrunc}`++ wrap.value.style.transform = `translate3d(0, ${currentY - offset}px, 0)`+ overflow.value.style.opacity = opacity+ }+ }++ /**+ * Drag start handler+ * @param event+ */+ function onDragStart (event: any): void {+ isDragging = false+ wrap.value.classList.remove(config.animClassName)++ // Always use touch with handler+ isDrugByHandler = handler.value && event.target.classList.contains(handler.value.className)+ if (isDrugByHandler) {+ isDrugByHandler = true+ isDragging = true+ }+ // Check if should drag modal+ else {+ // Do not close modal inside this div+ if (event.target.closest(`.${config.doNotTouchClassName}`)) { return }++ // Stop drag when content has scroll+ // wait until content scroll up to top+ if (content.value) {+ if (content.value.scrollTop > 0) { return }++ // wait until content scroll up inside+ const waitForScroll = content.value.querySelector(`.${config.whaitForScrollClassName}`)+ if (waitForScroll && waitForScroll.scrollTop > 0) { return }++ // wait until content scroll up inside Swiper+ const waitForScrollSlider = content.value.querySelector(`.swiper-slide-active .${config.whaitForScrollClassName}`)+ if (waitForScrollSlider && waitForScrollSlider.scrollTop > 0) { return }+ }+ }++ // Drag inside wrap+ if (event.target.closest(`.${wrap.value.className}`)) { isDragging = true }++ if (isDragging) {+ event.type === 'touchstart'+ ? initialY = event.touches[0].clientY+ : initialY = event.clientY+ }+ }++ /**+ * Dragging handler+ * @param event+ */+ function onDragging (event: any): void {+ if (isDragging) {+ event.type === 'touchmove'+ ? currentY = event.touches[0].clientY - initialY+ : currentY = event.clientY - initialY++ setTranslate()+ }+ }++ /**+ * Drag end handler+ */+ function onDragEnd (): void {+ if (currentY >= 80) {+ closeModal()+ }+ else {+ currentY = 0+ setTranslate()+ if (isDragging) { wrap.value.classList.add(config.animClassName) }+ }+ }++ /**+ * Transition end handler+ */+ function onTransitionEnd (): void {+ wrap.value.removeEventListener('transitionend', onTransitionEnd)+ currentY = 0+ wrap.value.style.transform = ''+ overflow.value.style.opacity = ''+ if (onClose) { onClose() }+ }++ /**+ * Clode modal+ */+ function closeModal (): void {+ isDragging = false+ isDrugByHandler = false++ currentY = container.value.clientHeight+ wrap.value.classList.add(config.animClassName)+ overflow.value.style.opacity = 0+ setTranslate()++ wrap.value.addEventListener('transitionend', onTransitionEnd)+ }++ /**+ * onUnmounted+ */+ onUnmounted(() => {+ if (!container || !container.value) { return }+ container.value.removeEventListener('touchstart', onDragStart)+ container.value.removeEventListener('touchmove', onDragging)+ container.value.removeEventListener('touchend', onDragEnd)+ container.value.removeEventListener('mouseup', onDragEnd)+ })++ return {+ initTouchModal,+ closeModal+ }+}diff --git a/components/layout/LayoutMobile.vue b/components/layout/LayoutMobile.vueindex b6d12b17..3637cfa0 100644--- a/components/layout/LayoutMobile.vue+++ b/components/layout/LayoutMobile.vue@@ -694,6 +694,7 @@ export default {CurrencyModalTrnForm(v-if="$store.getters['wallets/hasWallets'] && $store.getters['categories/hasCategories']"+ :isShow="$store.state.trnForm.show")TrnModalWalletModal(:slider="slider")@@ -781,8 +782,11 @@ export default {Portal(v-if="activeTab === 'walletsSort'"to="modal"+ key="walletsSort")ModalBottom(+ isShow+ key="walletsSort"@onClose="$store.dispatch('ui/setActiveTab', 'stat')")template(#default="{ closeModal }")diff --git a/components/layout/LayoutPc.vue b/components/layout/LayoutPc.vueindex b4ec9112..b0a4e415 100644--- a/components/layout/LayoutPc.vue+++ b/components/layout/LayoutPc.vue@@ -25,7 +25,10 @@ export default {//- modalsCategoryModalCurrencyModal- TrnForm(v-if="$store.getters['wallets/hasWallets'] && $store.getters['categories/hasCategories']")+ TrnForm(+ v-if="$store.getters['wallets/hasWallets'] && $store.getters['categories/hasCategories']"+ :isShow="$store.state.trnForm.show"+ )TrnModalWalletModaldiff --git a/components/modal/ModalBottom.vue b/components/modal/ModalBottom.vueindex 2e85ab07..1b5317c5 100644--- a/components/modal/ModalBottom.vue+++ b/components/modal/ModalBottom.vue@@ -1,98 +1,96 @@<script>-import { ref } from '@nuxtjs/composition-api'-import useTouchClose from '~/composables/useTouchClose'+import { ref, watch, reactive, toRefs } from '@nuxtjs/composition-api'+import useTouchClose from '~/components/base/modal/useTouchClose.ts'export default {name: 'ModalBottom',props: {+ isShow: {+ type: Boolean,+ default: true+ },+center: {type: Boolean,default: false},+title: {type: String,default: null},+paddingless: {type: Boolean,default: false}},- setup (props, ctx) {- const scrollContainer = ref(null)- const scrollContent = ref(null)- const scrollOverflow = ref(null)- const scrollDragger = ref(null)-- const { onCloseModal } = useTouchClose({- container: scrollContainer,- content: scrollContent,- overflow: scrollOverflow,- dragger: scrollDragger,- onClose: () => {- if (ctx.listeners.onClose) {- ctx.listeners.onClose()- }- if (ctx.listeners && ctx.listeners.afterClose) {- ctx.listeners.afterClose()- }- }+ setup (props, { listeners }) {+ const { isShow } = toRefs(props)+ const { initTouchModal, closeModal } = useTouchClose()++ const wrappers = reactive({+ container: ref(null),+ content: ref(null),+ handler: ref(null),+ overflow: ref(null),+ wrap: ref(null)})- return {- scrollContainer,- scrollContent,- scrollOverflow,- scrollDragger,- onCloseModal- }- },+ watch(isShow, (value) => {+ value && setTimeout(() => {+ initTouchModal({+ ...toRefs(wrappers),+ onClose: () => {+ if (listeners.onClose) {+ listeners.onClose()+ }+ if (listeners && listeners.afterClose) {+ listeners.afterClose()+ }+ }+ })+ }, 10)+ }, { immediate: true })- data () {return {- isShowed: false+ ...toRefs(wrappers),+ closeModal}- },-- mounted () {- this.isShowed = true}}</script><template lang="pug">-.modalBottom.noDrag(+.modalBottom(:style="{ maxHeight: `${$store.state.ui.height}px`}":class="{ _center: center, _paddingless: paddingless }"- ref="scrollContainer"+ v-show="isShow"+ ref="container")//- Overflow//--------------------------------------- transition(name="fadeIn" appear)+ transition(name="baseModalOveflowAnim" appear).modalBottom__overflow(- v-if="isShowed"- ref="scrollOverflow"- @click="onCloseModal"+ v-show="isShow"+ ref="overflow"+ @click="closeModal")//- Wrap//--------------------------------------- transition(- appear- name="slide2"- @after-leave="afterClose"- )+ transition(name="baseModalWrapAnim" appear).modalBottom__wrap(- v-if="isShowed"- ref="scrollDragger"+ v-show="isShow"+ ref="wrap")//- Empty Header//--------------------------------------div(v-if="$slots.emptyHeader"- @click="onCloseModal"+ @click="closeModal")slot(name="emptyHeader")@@ -111,7 +109,7 @@ export default {//--------------------------------------.modalBottom__scroll(:style="{ maxHeight: `${$store.state.ui.height - 100}px`}"- ref="scrollContent"+ ref="content")//- Descriptionslot(name="description")@@ -123,15 +121,46 @@ export default {//- Buttons 2 collumns.modalLinks._two- slot(name="btnsTwo" :closeModal="onCloseModal")+ slot(name="btnsTwo" :closeModal="closeModal")//- Default- slot(:closeModal="onCloseModal")+ slot(:closeModal="closeModal")</template><style lang="stylus" scoped>@import '~assets/stylus/variables'+$transition-style = cubic-bezier(.17, .04, .03, 1)++.baseModalOveflowAnim+ &-enter-active+ &-leave-active+ opacity 1+ transition all 250ms $transition-style++ &-enter+ &-leave-to+ opacity 0++.baseModalWrapAnim+ &-enter-active+ &-leave-active+ opacity 0+ transform translate3d(0, 50px, 0)+ transition opacity 300ms $transition-style, transform 250ms $transition-style++ &-enter-to+ transform translate3d(0, 0, 0)++ &-leave+ &-enter-to+ &-leave-to+ opacity 1++ &-leave-to+ transform translate3d(0, 200%, 0)+ transition opacity 400ms $transition-style, transform 400ms $transition-style+.modalBottom&__wrap&._anim@@ -146,7 +175,7 @@ export default {@import '~assets/stylus/variables'.modalBottom- z-index 10+ z-index 100position fixedleft 0bottom 0@@ -161,15 +190,18 @@ export default {width 100%height 100%background var(--c-bg-14)+ anim()&__wrap+ // overflow hiddenposition relativedisplay flexflex-grow 1flex-flow column nowrapmax-width 440pxmargin-right auto- border-radius 0 0 $m7 $m7+ background var(--c-bg-4)+ border-radius $m7 $m7 0 0@media $media-laptopmax-width 460px@@ -182,11 +214,12 @@ export default {max-height calc(90vh - 80px)padding $m7background var(--c-bg-4)+ border-radius $m7 $m7 0 0scrollbar()@media $media-laptoppadding $m9- border-radius 0 0 $m7 $m7+ border-radius $m7^[0]._paddingless &padding 0diff --git a/components/shared/BaseModal.vue b/components/shared/BaseModal.vuedeleted file mode 100644index 0bafa1eb..00000000--- a/components/shared/BaseModal.vue+++ /dev/null@@ -1,197 +0,0 @@-<script>-import { ref } from '@nuxtjs/composition-api'-import useTouchClose from '~/composables/useTouchClose'--export default {- name: 'BaseModal',-- props: {- title: {- type: String,- default: null- },- show: {- type: Boolean,- required: true- },- position: {- type: String,- default: null- }- },-- setup (props, ctx) {- const scrollContainer = ref(null)- const scrollContent = ref(null)- const scrollOverflow = ref(null)- const scrollDragger = ref(null)-- useTouchClose({- container: scrollContainer,- content: scrollContent,- overflow: scrollOverflow,- dragger: scrollDragger,- onClose: () => ctx.listeners.onClose && ctx.listeners.onClose()- })-- return {- scrollContainer,- scrollContent,- scrollOverflow,- scrollDragger- }- },-- data () {- return {- headerHeight: 0- }- },-- computed: {- modalStyle () {- return {}- }- },-- methods: {- afterClose () {- if (this.$listeners.afterClose) {- this.$listeners.afterClose()- }- },-- onClose () {- this.$listeners.onClose()- }- }-}-</script>--<template lang="pug">-portal(to="modal" v-if="show")- .baseModal(- ref="scrollContainer"- :class="{ _opened: show }"- )- transition(name="fadeIn" appear)- .baseModal__overflow(- v-show="show"- ref="scrollOverflow"- @click="onClose"- )-- transition(name="hey" appear @after-leave="afterClose")- .baseModal__wrap(- ref="scrollDragger"- v-show="show"- )- .baseModal__header(- @click="onClose"- ref="header"- )- .baseModal__header__title(v-if="title") {{ title }}- .baseModal__header__close: .mdi.mdi-close-- .baseModal__scroll(- :style="modalStyle"- ref="scrollContent"- )- slot()-</template>--<style lang="stylus" scoped>-@import "~assets/stylus/variables/animations"-@import "~assets/stylus/variables/fonts"-@import "~assets/stylus/variables/media"-@import "~assets/stylus/variables/margins"--.baseModal- z-index 10- position fixed- left 0-- &._opened- width 100%- height 100%-- @media $media-phone- bottom 0-- @media $media-laptop- top 0- left 0px-- &__overflow- position absolute- left 0- bottom 0- width 100%- height 100%- background var(--c-bg-14)- anim()-- @media $media-laptop- display none-- &__wrap- overflow hidden- z-index 2- position absolute- left 0- bottom 0- display flex- width 100%- flex-grow 1- flex-flow column nowrap- background var(--c-bg-2)- border-radius $m6-- &._anim- anim(400ms)-- @media $media-phone- border-radius $m6 $m6 0 0-- /.light-mode &- background var(--c-bg-2)-- &__scroll- overflow hidden- overflow-y auto- max-height 100%- padding $m7 0- scrollbar()-- &__header- cursor pointer- position relative- display flex- align-items center- justify-content space-between- padding $m7- color var(--c-font-3)- font-size 22px- font-weight 700- letter-spacing 1px- fontFamilyNunito()-- /.light-mode &- color var(--c-font-4)-- &:hover- &:active- background var(--c-bg-5)-- &__title- flex-grow 1-- &__close- color var(--c-font-4)- font-size 20px-- &__icon- position absolute- top -24px- right $m7-</style>diff --git a/components/stat/StatCustomizeMenuMobile.vue b/components/stat/StatCustomizeMenuMobile.vueindex 4ba26f67..0a2a1176 100644--- a/components/stat/StatCustomizeMenuMobile.vue+++ b/components/stat/StatCustomizeMenuMobile.vue@@ -46,7 +46,7 @@ div:title="$t('settings.customize')")- BaseModal(+ ModalBottom(:show="visibleCustomizeMenu":title="$t('settings.customize')"@onClose="visibleCustomizeMenu = !visibleCustomizeMenu"diff --git a/components/trnForm/TrnForm.vue b/components/trnForm/TrnForm.vueindex b1d88459..9fe4af35 100644--- a/components/trnForm/TrnForm.vue+++ b/components/trnForm/TrnForm.vue@@ -2,11 +2,12 @@// @ts-ignoreimport Swiper from 'swiper'import 'swiper/swiper-bundle.css'-import { ref, useContext } from '@nuxtjs/composition-api'+import { ref, computed, watch, reactive, toRefs, useContext } from '@nuxtjs/composition-api'// @ts-ignoreimport generateId from '~/utils/id'// @ts-ignore-import useTouchClose from '~/composables/useTouchClose'+import useTouchClose from '~/components/base/modal/useTouchClose.ts'+// @ts-ignoreimport useCalculator from '~/components/trnForm/calculator/useCalculator'// @ts-ignore@@ -17,118 +18,121 @@ import { successEmo, random } from '~/assets/js/emo'export default {name: 'TrnForm',- setup () {+ props: {+ isShow: {+ type: Boolean,+ default: false+ }+ },++ setup (props: any) {const { store } = useContext()- const scrollContainer = ref(null)- const scrollContent = ref(null)- const scrollOverflow = ref(null)- const scrollDragger = ref(null)-- // @ts-ignore- const { onCloseModal } = useTouchClose({- container: scrollContainer,- content: scrollContent,- overflow: scrollOverflow,- dragger: scrollDragger,- noDragClasss: '.noDrag',- onClose: () => store.dispatch('trnForm/closeTrnForm')+ const { isShow } = toRefs(props)+ const { initTouchModal, closeModal } = useTouchClose()++ const wrappers = reactive({+ container: ref(null),+ content: ref(null),+ handler: ref(null),+ overflow: ref(null),+ wrap: ref(null),+ config: {+ doNotTouchClassName: 'doNotCloseTrnModal'+ }})- return {- scrollContainer,- scrollContent,- scrollOverflow,- scrollDragger,- onCloseModal+ const slider = ref<any>(null)+ const getHeight = ref<any>(null)+ const sliderObj = ref<any>(null)+ const { clearExpression } = useCalculator()++ function setTrnFormHeight () {+ const trnFormHeight = store.state.trnForm.height+ const height = getHeight.value.clientHeight + 8+ const trnFormHeaderHeight = 0+ const newTrnFormHeight = height - trnFormHeaderHeight++ if (trnFormHeight !== newTrnFormHeight) {+ store.commit('trnForm/setTrnFormHeight', newTrnFormHeight)+ }}- },- data () {+ /**+ * Watch isShow+ */+ watch(isShow, (value) => {+ if (value) {+ setTimeout(() => {+ initTouchModal({+ ...toRefs(wrappers),+ onClose: () => store.dispatch('trnForm/closeTrnForm')+ })++ setTrnFormHeight()+ if (sliderObj.value) {+ sliderObj.value.update()+ sliderObj.value.slideTo(0, 0)+ }+ else {+ sliderObj.value = new Swiper(slider.value, {+ slidesPerView: 1,+ autoHeight: true,+ initialSlide: 0,+ noSwipingClass: 'trnFormNoSwiping',+ shortSwipes: false,+ longSwipesRatio: 0.1,+ longSwipesMs: 60+ })+ }+ }, 10)+ }+ else {+ clearExpression()+ }+ }, { immediate: true })++ /**+ * Watch amountType+ */+ const amountType = computed(() => store.state.trnForm.values.amountType)+ watch(amountType, () => {+ setTimeout(() => {+ setTrnFormHeight()+ sliderObj.value.update()+ }, 10)+ })+return {- slider: null+ ...toRefs(wrappers),+ closeModal,++ sliderObj,+ slider,+ getHeight,++ amountType}},computed: {- // @ts-ignore- show () {+ show (): any {// @ts-ignorereturn this.$store.state.trnForm.show},- // @ts-ignore- isTransfer () {+ isTransfer (): any {// @ts-ignorereturn this.$store.state.trnForm.values.amountType === 2},- // @ts-ignore- amountType () {- // @ts-ignore- return this.$store.state.trnForm.values.amountType- },-- isShowFirstWallets () {+ isShowFirstWallets (): any {// @ts-ignoreif (this.$store.getters['wallets/walletsSortedIds'].length >= 3) { return true }return false}},- watch: {- // @ts-ignore- show: {- // @ts-ignore- handler (show) {- const { clearExpression } = useCalculator()-- if (show) {- // @ts-ignore- this.$nextTick(() => {- // @ts-ignore- this.setTrnFormHeight()- // @ts-ignore- if (this.slider) {- // @ts-ignore- this.slider.update()- // @ts-ignore- this.slider.slideTo(0, 0)- }- else {- // @ts-ignore- this.slider = new Swiper(this.$refs.slider, {- slidesPerView: 1,- autoHeight: true,- initialSlide: 0,- noSwipingClass: 'trnFormNoSwiping',- shortSwipes: false,- longSwipesRatio: 0.1,- longSwipesMs: 60- })- }- })- }- else {- clearExpression()- }- },- immediate: true- },-- amountType () {- // @ts-ignore- this.$nextTick(() => {- // @ts-ignore- this.setTrnFormHeight()- setTimeout(() => {- // @ts-ignore- this.slider.update()- }, 1)- })- }- },-methods: {handleSubmitForm () {try {@@ -255,27 +259,31 @@ export default {<template lang="pug">.trnForm(v-if="$store.getters['wallets/hasWallets'] && $store.getters['categories/hasCategories']"- ref="scrollContainer"+ v-show="isShow"+ ref="container")//- Overflow- transition(name="hey")+ transition(name="baseModalOveflowAnim" appear).trnForm__overflow(- ref="scrollOverflow"- v-if="show"- @click.prevent="onCloseModal"+ ref="overflow"+ v-show="isShow"+ @click="closeModal")//- wrap- transition(name="trnFormAnimation")+ transition(name="baseModalWrapAnim" appear).trnForm__wrap(- v-show="show"+ v-show="isShow":style="{ maxHeight: `${$store.state.trnForm.height}px` }"- ref="scrollDragger"+ ref="wrap")- .trnForm__handler+ .trnForm__handler(+ @click="closeModal"+ ref="handler"+ )//- Content- .trnForm__scroll(ref="scrollContent")+ .trnForm__scroll(ref="content").trnForm__content.swiper-container(ref="slider").swiper-wrapper@@ -313,9 +321,9 @@ export default {TrnFormHeaderTransfer(v-if="isTransfer").swiper-slide(:style="{ minHeight: `${$store.state.trnForm.height}px` }")- div(v-if="slider")+ div(v-if="sliderObj")TrnFormTrns(- :slider="slider"+ :slider="sliderObj"onlyList)@@ -335,7 +343,49 @@ export default {@import '~assets/stylus/variables/margins'@import '~assets/stylus/variables/media'+$transition-style = cubic-bezier(.17, .04, .03, 1)++.baseModalOveflowAnim+ &-enter-active+ &-leave-active+ opacity 1+ transition all 250ms $transition-style++ &-enter+ &-leave-to+ opacity 0++.baseModalWrapAnim+ &-enter-active+ &-leave-active+ opacity 0+ transform translate3d(0, 50px, 0)+ transition opacity 300ms $transition-style, transform 250ms $transition-style++ &-enter-to+ transform translate3d(0, 0, 0)++ &-leave+ &-enter-to+ &-leave-to+ opacity 1++ &-leave-to+ transform translate3d(0, 200%, 0)+ transition opacity 400ms $transition-style, transform 400ms $transition-style+.trnForm+ &__overflow+ position fixed+ top 0+ right 0+ width 100%+ height 100%+ anim()++ @media $media-laptop+ width 440px+&__titlepadding $m8padding-bottom 0diff --git a/components/trnForm/TrnFormModalTransferFrom.vue b/components/trnForm/TrnFormModalTransferFrom.vuedeleted file mode 100644index 9babfe5c..00000000--- a/components/trnForm/TrnFormModalTransferFrom.vue+++ /dev/null@@ -1,25 +0,0 @@-<script>-export default {- methods: {- handleSetWallet (walletId) {- this.$store.commit('trnForm/toogleTrnFormModal', 'transferFrom')- this.$store.commit('trnForm/setTrnFormValues', {- walletFromId: walletId,- walletId- })- }- }-}-</script>--<template lang="pug">-TrnFormModal(- v-if="$store.state.trnForm.modal.transferFrom"- :show="$store.state.trnForm.modal.transferFrom"- title="Transfer from wallet"- @onClose="$store.commit('trnForm/toogleTrnFormModal', 'transferFrom')"-)- WalletsList3(- @onClick="handleSetWallet"- )-</template>diff --git a/components/trnForm/TrnFormModalTransferTo.vue b/components/trnForm/TrnFormModalTransferTo.vuedeleted file mode 100644index bd56d1b6..00000000--- a/components/trnForm/TrnFormModalTransferTo.vue+++ /dev/null@@ -1,25 +0,0 @@-<script>-export default {- methods: {- handleSetWallet (walletId) {- this.$store.commit('trnForm/toogleTrnFormModal', 'transferTo')- this.$store.commit('trnForm/setTrnFormValues', {- walletToId: walletId,- walletId- })- }- }-}-</script>--<template lang="pug">-TrnFormModal(- v-if="$store.state.trnForm.modal.transferTo"- :show="$store.state.trnForm.modal.transferTo"- title="Transfer to wallet"- @onClose="$store.commit('trnForm/toogleTrnFormModal', 'transferTo')"-)- WalletsList3(- @onClick="handleSetWallet"- )-</template>diff --git a/components/trnForm/TrnFormModal.vue b/components/trnForm/modal/TrnFormModal.vuesimilarity index 58%rename from components/trnForm/TrnFormModal.vuerename to components/trnForm/modal/TrnFormModal.vueindex cfcf833f..6d077d1c 100644--- a/components/trnForm/TrnFormModal.vue+++ b/components/trnForm/modal/TrnFormModal.vue@@ -1,6 +1,6 @@-<script>-import { ref } from '@nuxtjs/composition-api'-import useTouchClose from '~/composables/useTouchClose'+<script lang="ts">+import { ref, watch, reactive, toRefs } from '@nuxtjs/composition-api'+import useTouchClose from '~/components/base/modal/useTouchClose.ts'export default {props: {@@ -8,41 +8,60 @@ export default {type: String,default: null},- show: {++ isShow: {type: Boolean,- required: true+ required: false},+position: {type: String,default: null},+ doNotTouchClassName: {+ type: String,+ default: null+ },+noPadding: {type: Boolean,default: false}},- setup (props, ctx) {- const scrollContainer = ref(null)- const scrollContent = ref(null)- const scrollOverflow = ref(null)- const scrollDragger = ref(null)-- const { onCloseModal } = useTouchClose({- container: scrollContainer,- content: scrollContent,- overflow: scrollOverflow,- dragger: scrollDragger,- onClose: () => ctx.listeners.onClose && ctx.listeners.onClose()+ // @ts-ignore+ setup (props: any, { listeners }) {+ const { isShow, doNotTouchClassName } = toRefs(props)+ const { initTouchModal, closeModal } = useTouchClose()++ console.log('doNotTouchClassName', doNotTouchClassName.value)++ const wrappers = reactive({+ container: ref(null),+ content: ref(null),+ handler: ref(null),+ overflow: ref(null),+ wrap: ref(null),+ config: {+ doNotTouchClassName: doNotTouchClassName.value ? doNotTouchClassName.value : 'doNotCloseTrnModalInside'+ }})+ watch(isShow, (value) => {+ if (value) {+ setTimeout(() => {+ initTouchModal({+ ...toRefs(wrappers),+ onClose: listeners.onClose+ })+ }, 10)+ }+ }, { immediate: true })+return {- scrollContainer,- scrollContent,- scrollOverflow,- scrollDragger,- onCloseModal+ ...toRefs(wrappers),+ closeModal}},@@ -53,19 +72,24 @@ export default {},computed: {- modalStyle () {+ modalStyle (): any {+ // @ts-ignoreif (this.$store.state.trnForm.height < this.$store.state.ui.height) {+ // @ts-ignoreif (this.position === 'bottom') {return {+ // @ts-ignoremaxHeight: `${this.$store.state.trnForm.height - this.headerHeight}px`}}return {+ // @ts-ignoreheight: `${this.$store.state.trnForm.height - this.headerHeight}px`}}else {return {+ // @ts-ignoreheight: `${this.$store.state.ui.height - this.headerHeight}px`}}@@ -81,19 +105,25 @@ export default {methods: {afterClose () {+ // @ts-ignoreif (this.$listeners.afterClose) {+ // @ts-ignorethis.$listeners.afterClose()}},updateHeight () {+ // @ts-ignorethis.$nextTick(() => {+ // @ts-ignorethis.headerHeight = this.$refs.header.clientHeight})},onClose () {+ // @ts-ignoreif (this.$listeners.onClose) {+ // @ts-ignorethis.$listeners.onClose()}}@@ -102,22 +132,25 @@ export default {</script><template lang="pug">-.trnFormModal.noDrag(ref="scrollContainer")- transition(name="fadeIn" appear)+.trnFormModal(+ ref="container"+ v-show="isShow"+)+ transition(name="baseModalOveflowAnim" appear).trnFormModal__overflow(- v-show="show"- ref="scrollOverflow"- @click="onCloseModal"+ v-show="isShow"+ ref="overflow"+ @click="closeModal")- transition(name="slide" appear @after-leave="afterClose")+ transition(name="baseModalWrapAnim" appear).trnFormModal__wrap(- v-show="show"- ref="scrollDragger"+ v-show="isShow"+ ref="wrap").trnFormModal__header(ref="header"- @click="onCloseModal"+ @click="closeModal").trnFormModal__header__title(v-if="title") {{ title }}.trnFormModal__header__close: .mdi.mdi-close@@ -125,9 +158,9 @@ export default {.trnFormModal__scroll(:style="modalStyle":class="{ _noPadding: noPadding }"- ref="scrollContent"+ ref="content")- slot()+ slot</template><style lang="stylus" scoped>@@ -136,8 +169,36 @@ export default {@import '~assets/stylus/variables/media'@import '~assets/stylus/variables/margins'+.baseModalOveflowAnim+ &-enter-active+ &-leave-active+ transition opacity 350ms ease++ &-enter+ &-leave-to+ opacity 0++.baseModalWrapAnim+ &-enter-active+ &-leave-active+ opacity 0+ transform translate3d(0, 50px, 0)+ transition opacity 300ms $transition-style, transform 250ms $transition-style++ &-enter-to+ transform translate3d(0, 0, 0)++ &-leave+ &-enter-to+ &-leave-to+ opacity 1++ &-leave-to+ transform translate3d(0, 200%, 0)+ transition opacity 400ms $transition-style, transform 400ms $transition-style+.trnFormModal- z-index 3+ z-index 100position absoluteleft 0width 100%@@ -171,7 +232,7 @@ export default {border-radius $m6&._anim- anim(400ms)+ anim(200ms)@media $media-phoneborder-radius $m6 $m6 0 0@@ -188,6 +249,7 @@ export default {&._noPaddingoverflow hidden+ margin-bottom (- $m7)padding-bottom 0&__headerdiff --git a/components/trnForm/TrnFormModalCalendar.vue b/components/trnForm/modal/TrnFormModalCalendar.vuesimilarity index 91%rename from components/trnForm/TrnFormModalCalendar.vuerename to components/trnForm/modal/TrnFormModalCalendar.vueindex 2d65df0e..2f6466a5 100644--- a/components/trnForm/TrnFormModalCalendar.vue+++ b/components/trnForm/modal/TrnFormModalCalendar.vue@@ -14,6 +14,10 @@ export default {},computed: {+ isShow () {+ return this.$store.state.trnForm.modal.calendar+ },+date () {return this.$store.state.trnForm.values.date}@@ -41,11 +45,11 @@ export default {</script><template lang="pug">-TrnFormModal(- v-if="$store.state.trnForm.modal.calendar"- :show="$store.state.trnForm.modal.calendar"- title="Date"+LazyTrnFormModal.doNotCloseTrnModal(+ v-if="isShow"+ :isShow="isShow":position="$store.state.ui.mobile ? 'bottom' : null"+ title="Date"@onClose="$store.commit('trnForm/toogleTrnFormModal', 'calendar')")Datepicker(diff --git a/components/trnForm/TrnFormModalCats.vue b/components/trnForm/modal/TrnFormModalCats.vuesimilarity index 67%rename from components/trnForm/TrnFormModalCats.vuerename to components/trnForm/modal/TrnFormModalCats.vueindex f41c1cc9..3770793b 100644--- a/components/trnForm/TrnFormModalCats.vue+++ b/components/trnForm/modal/TrnFormModalCats.vue@@ -1,7 +1,7 @@<script>export default {computed: {- show () {+ isShow () {return this.$store.state.trnForm.modal.categories}}@@ -9,13 +9,12 @@ export default {</script><template lang="pug">-TrnFormModal(- v-if="$store.state.trnForm.modal.categories"- :show="$store.state.trnForm.modal.categories"- :title="$t('categories.name')"+TrnFormModal.doNotCloseTrnModal(+ :isShow="isShow":position="$store.state.ui.mobile ? 'bottom' : null"- noPadding+ :title="$t('categories.name')"@onClose="$store.commit('trnForm/toogleTrnFormModal', 'categories')"+ noPadding)- TrnFormCategories(:show="show")+ TrnFormCategories(:show="isShow")</template>diff --git a/components/trnForm/TrnFormModalCatsChild.vue b/components/trnForm/modal/TrnFormModalCatsChild.vuesimilarity index 88%rename from components/trnForm/TrnFormModalCatsChild.vuerename to components/trnForm/modal/TrnFormModalCatsChild.vueindex 94a68e7e..d1f00de9 100644--- a/components/trnForm/TrnFormModalCatsChild.vue+++ b/components/trnForm/modal/TrnFormModalCatsChild.vue@@ -30,11 +30,11 @@ export default {</script><template lang="pug">-TrnFormModal(- v-if="$store.state.trnForm.modal.categoriesChild"- :show="$store.state.trnForm.modal.categoriesChild"- :title="id && category && category.name"+TrnFormModal.doNotCloseTrnModal(+ :isShow="$store.state.trnForm.modal.categoriesChild":position="$store.state.ui.mobile ? 'bottom' : null"+ :title="id && category && category.name"+ doNotTouchClassName="doNotCloseTrnModalInside"@onClose="onClose")template(v-if="id && category")diff --git a/components/trnForm/TrnFormModalDescription.vue b/components/trnForm/modal/TrnFormModalDescription.vuesimilarity index 97%rename from components/trnForm/TrnFormModalDescription.vuerename to components/trnForm/modal/TrnFormModalDescription.vueindex 98402e0a..f4625e53 100644--- a/components/trnForm/TrnFormModalDescription.vue+++ b/components/trnForm/modal/TrnFormModalDescription.vue@@ -42,11 +42,11 @@ export default {</script><template lang="pug">-TrnFormModal(+LazyTrnFormModal.doNotCloseTrnModal(v-if="isShow"- :show="isShow"- :title="$t('trnForm.description.title')"+ :isShow="isShow":position="$store.state.ui.mobile ? 'bottom' : null"+ :title="$t('trnForm.description.title')"@onClose="$store.commit('trnForm/toogleTrnFormModal', 'description')").descriptiondiff --git a/components/trnForm/modal/TrnFormModalTransferFrom.vue b/components/trnForm/modal/TrnFormModalTransferFrom.vuenew file mode 100644index 00000000..ac37b042--- /dev/null+++ b/components/trnForm/modal/TrnFormModalTransferFrom.vue@@ -0,0 +1,35 @@+<script>+import { computed, useContext } from '@nuxtjs/composition-api'++export default {+ name: 'TrnFormModalTransferFrom',++ setup () {+ const { store } = useContext()+ const isShow = computed(() => store.state.trnForm.modal.transferFrom)++ function setWalletFromId (walletId) {+ store.commit('trnForm/toogleTrnFormModal', 'transferFrom')+ store.commit('trnForm/setTrnFormValues', {+ walletFromId: walletId,+ walletId+ })+ }++ return {+ isShow,+ setWalletFromId+ }+ }+}+</script>++<template lang="pug">+LazyTrnFormModal.doNotCloseTrnModal(+ v-if="isShow"+ :isShow="isShow"+ title="Transfer from wallet"+ @onClose="$store.commit('trnForm/toogleTrnFormModal', 'transferFrom')"+)+ WalletsList3(@onClick="setWalletFromId")+</template>diff --git a/components/trnForm/modal/TrnFormModalTransferTo.vue b/components/trnForm/modal/TrnFormModalTransferTo.vuenew file mode 100644index 00000000..54628bb1--- /dev/null+++ b/components/trnForm/modal/TrnFormModalTransferTo.vue@@ -0,0 +1,35 @@+<script>+import { computed, useContext } from '@nuxtjs/composition-api'++export default {+ name: 'TrnFormModalTransferTo',++ setup () {+ const { store } = useContext()+ const isShow = computed(() => store.state.trnForm.modal.transferTo)++ function setWalletToId (walletId) {+ store.commit('trnForm/toogleTrnFormModal', 'transferTo')+ store.commit('trnForm/setTrnFormValues', {+ walletToId: walletId,+ walletId+ })+ }++ return {+ isShow,+ setWalletToId+ }+ }+}+</script>++<template lang="pug">+LazyTrnFormModal.doNotCloseTrnModal(+ v-if="isShow"+ :isShow="isShow"+ title="Transfer to wallet"+ @onClose="$store.commit('trnForm/toogleTrnFormModal', 'transferTo')"+)+ WalletsList3(@onClick="setWalletToId")+</template>diff --git a/components/trnForm/TrnFormModalTrn.vue b/components/trnForm/modal/TrnFormModalTrn.vuesimilarity index 99%rename from components/trnForm/TrnFormModalTrn.vuerename to components/trnForm/modal/TrnFormModalTrn.vueindex 5de8dfa7..f7273f84 100644--- a/components/trnForm/TrnFormModalTrn.vue+++ b/components/trnForm/modal/TrnFormModalTrn.vue@@ -78,7 +78,7 @@ export default {</script><template lang="pug">-TrnFormModal(+TrnFormModal.doNotCloseTrnModal(v-if="trnId":show="$store.state.trnForm.modal.trn":position="$store.state.ui.mobile ? 'bottom' : null"diff --git a/components/trnForm/TrnFormModalWallets.vue b/components/trnForm/modal/TrnFormModalWallets.vuesimilarity index 83%rename from components/trnForm/TrnFormModalWallets.vuerename to components/trnForm/modal/TrnFormModalWallets.vueindex 01d8be2c..c9fd1c1b 100644--- a/components/trnForm/TrnFormModalWallets.vue+++ b/components/trnForm/modal/TrnFormModalWallets.vue@@ -10,11 +10,10 @@ export default {</script><template lang="pug">-TrnFormModal(- v-if="$store.state.trnForm.modal.wallets"- :show="$store.state.trnForm.modal.wallets"- :title="$t('wallets.title')"+TrnFormModal.doNotCloseTrnModal(+ :isShow="$store.state.trnForm.modal.wallets":position="$store.state.ui.mobile ? 'bottom' : null"+ :title="$t('wallets.title')"@onClose="$store.commit('trnForm/toogleTrnFormModal', 'wallets')").trnFormWalletsList@@ -28,7 +27,7 @@ TrnFormModal(</template><style lang="stylus">-@import "~assets/stylus/variables/margins"+@import '~assets/stylus/variables/margins'.trnFormWalletsList.walletsList__tooglediff --git a/components/wallets/sort/WalletsSort.vue b/components/wallets/sort/WalletsSort.vueindex f749fe07..adf21e4b 100644--- a/components/wallets/sort/WalletsSort.vue+++ b/components/wallets/sort/WalletsSort.vue@@ -3,6 +3,8 @@ import draggable from 'vuedraggable'import { successEmo, random } from '~/assets/js/emo'export default {+ name: 'WalletsSort',+components: {draggable},diff --git a/composables/useTouchClose.js b/composables/useTouchClose.jsdeleted file mode 100644index 8ba4a10a..00000000--- a/composables/useTouchClose.js+++ /dev/null@@ -1,144 +0,0 @@-import { ref, onMounted, onUnmounted } from '@nuxtjs/composition-api'--export default function useOnTouch ({ container, overflow, dragger, content, onClose, noDragClasss }) {- const isDragging = ref(false)- const initialY = ref(0)- const currentY = ref(0)- const currentX = ref(0)-- // setTranslate- const setTranslate = () => {- if (!dragger.value) { return }-- if (currentY.value === 0) {- dragger.value.style.transform = ''- if (overflow.value) {- overflow.value.style.opacity = ''- }- }- else if (currentY.value > 0) {- const containerHeight = container.value.clientHeight- const diff = (containerHeight - currentY.value) / (containerHeight / 100)- const diffTrunc = Math.trunc(diff)-- if (dragger.value) {- dragger.value.style.transform = `translate3d(0, ${currentY.value}px, 0)`- }- if (overflow.value) {- overflow.value.style.opacity = diffTrunc === 100 ? 1 : `0.${diffTrunc}`- }- }- // else if (currentY.value < 0) {- // const swiperWrapper = dragger.value.querySelector('.swiper-wrapper')- // dragger.value.style.maxHeight = '700px'- // swiperWrapper.style.height = '700px'- // }- }-- // onDragStart- const onDragStart = (event) => {- const isDrugByHandler = event.target.classList.contains('trnForm__handler')-- // wait- if (!isDrugByHandler) {- // stop trnFormModal drag when content has scroll- // wait until content scroll up to top- if (content.value && content.value.scrollTop > 0) { return }-- if (event.target.closest('.doNotCloseModal')) {- isDragging.value = false- return- }-- const waitForScrollSlider = content.value.querySelector('.swiper-slide-active .waitForScroll')- if (waitForScrollSlider && waitForScrollSlider.scrollTop > 0) { return }-- const waitForScroll = content.value.querySelector('.waitForScroll')- if (waitForScroll && waitForScroll.scrollTop > 0) { return }- }-- if (dragger.value) {- dragger.value.classList.remove('_anim')-- event.type === 'touchstart'- ? initialY.value = event.touches[0].clientY- : initialY.value = event.clientY-- if (event.target.closest(`.${dragger.value.className}`)) { isDragging.value = true }- if (noDragClasss && event.target.closest(noDragClasss)) { isDragging.value = false }- }- }-- // onDragging- const onDragging = (event) => {- if (isDragging.value) {- event.type === 'touchmove'- ? currentY.value = event.touches[0].clientY - initialY.value- : currentY.value = event.clientY - initialY.value-- if ((Math.abs(currentY.value) < Math.abs(currentX.value))) { return }-- setTranslate()- }- }-- // onDragEnd- const onDragEnd = () => {- if (currentY.value >= 80) {- dragger.value.classList.add('_anim')- currentY.value = container.value.clientHeight- setTranslate()- resetPosition()- }- else {- currentY.value = 0- currentX.value = 0- setTranslate()- if (isDragging.value) { dragger.value.classList.add('_anim') }- }-- isDragging.value = false- }-- onMounted(() => {- if (!container.value) { return }- container.value.addEventListener('touchstart', onDragStart)- container.value.addEventListener('touchmove', onDragging)- container.value.addEventListener('touchend', onDragEnd)- container.value.addEventListener('mouseup', onDragEnd)- })-- onUnmounted(() => {- if (!container.value) { return }- container.value.removeEventListener('touchstart', onDragStart)- container.value.removeEventListener('touchmove', onDragging)- container.value.removeEventListener('touchend', onDragEnd)- container.value.removeEventListener('mouseup', onDragEnd)- })-- const resetPosition = () => {- onCloseModal()- }-- const onCloseModal = () => {- isDragging.value = false- dragger.value.classList.add('_anim')- currentY.value = container.value.clientHeight- setTranslate()-- if (onClose) {- setTimeout(() => {- onClose()- dragger.value.classList.remove('_anim')- initialY.value = 0- currentY.value = 0- currentX.value = 0- setTranslate()- }, 300)- }- }-- return {- onCloseModal- }-}