@@ -92,6 +92,25 @@ export function useSwipeToClose(
92
92
} ,
93
93
} )
94
94
95
+ const bindSwipe = computed ( ( ) => {
96
+ if ( props . swipeToClose === 'none' )
97
+ return
98
+ const translateDirection = ( ( ) => {
99
+ switch ( props . swipeToClose ) {
100
+ case 'up' :
101
+ case 'down' :
102
+ return 'translateY'
103
+ case 'left' :
104
+ case 'right' :
105
+ return 'translateX'
106
+ }
107
+ } ) ( )
108
+ return {
109
+ class : { 'vfm-bounce-back' : ! isSwiping . value } ,
110
+ style : { transform : `${ translateDirection } (${ - offset . value } px)` } ,
111
+ }
112
+ } )
113
+
95
114
watch (
96
115
( ) => isCollapsed . value ,
97
116
( val ) => {
@@ -100,6 +119,14 @@ export function useSwipeToClose(
100
119
} ,
101
120
)
102
121
122
+ watch (
123
+ ( ) => modelValueLocal . value ,
124
+ ( val ) => {
125
+ if ( val )
126
+ offset . value = 0
127
+ } ,
128
+ )
129
+
103
130
watch (
104
131
( ) => offset . value ,
105
132
( newValue , oldValue ) => {
@@ -116,6 +143,11 @@ export function useSwipeToClose(
116
143
} ,
117
144
)
118
145
146
+ function onTouchStartSwipeBanner ( e : TouchEvent ) {
147
+ if ( props . preventNavigationGestures )
148
+ e . preventDefault ( )
149
+ }
150
+
119
151
function canSwipe ( target ?: null | EventTarget ) : boolean {
120
152
const tagName = ( target as HTMLElement ) ?. tagName
121
153
if ( ! tagName || [ 'INPUT' , 'TEXTAREA' ] . includes ( tagName ) )
@@ -142,38 +174,6 @@ export function useSwipeToClose(
142
174
return allow && canSwipe ( ( target as HTMLElement ) ?. parentElement )
143
175
}
144
176
145
- watch (
146
- ( ) => modelValueLocal . value ,
147
- ( val ) => {
148
- if ( val )
149
- offset . value = 0
150
- } ,
151
- )
152
-
153
- const bindSwipe = computed ( ( ) => {
154
- if ( props . swipeToClose === 'none' )
155
- return
156
- const translateDirection = ( ( ) => {
157
- switch ( props . swipeToClose ) {
158
- case 'up' :
159
- case 'down' :
160
- return 'translateY'
161
- case 'left' :
162
- case 'right' :
163
- return 'translateX'
164
- }
165
- } ) ( )
166
- return {
167
- class : { 'vfm-bounce-back' : ! isSwiping . value } ,
168
- style : { transform : `${ translateDirection } (${ - offset . value } px)` } ,
169
- }
170
- } )
171
-
172
- function onTouchStartSwipeBanner ( e : TouchEvent ) {
173
- if ( props . preventNavigationGestures )
174
- e . preventDefault ( )
175
- }
176
-
177
177
return {
178
178
vfmContentEl,
179
179
swipeBannerEl,
0 commit comments