@@ -10,6 +10,7 @@ import { useFocusTrap } from '@vueuse/integrations/useFocusTrap'
1010import { useSnapPoints } from ' ./composables/useSnapPoints.ts'
1111
1212interface IProps {
13+ duration? : number
1314 snapPoints? : number []
1415 defaultBreakpoint? : number
1516 blocking? : boolean
@@ -23,6 +24,7 @@ const props = withDefaults(defineProps<IProps>(), {
2324 canSwipeClose: true ,
2425 canBackdropClose: true ,
2526 expandOnContentDrag: true ,
27+ duration: 250 ,
2628})
2729
2830const emit = defineEmits <{
@@ -61,6 +63,8 @@ const { activate, deactivate } = useFocusTrap([sheet, backdrop], { immediate: fa
6163const minHeightComputed = computed (() =>
6264 Math .ceil (sheetContentHeight .value + sheetHeaderHeight .value + sheetFooterHeight .value ),
6365)
66+ const transitionVisibility = computed (() => ` visibility ${props .duration }ms ease-in-out ` )
67+ const transitionOpacity = computed (() => ` opacity ${props .duration }ms ease-in-out ` )
6468
6569// Element styling and transforms
6670const { motionProperties } = useMotionProperties (sheet )
@@ -103,7 +107,12 @@ const open = () => {
103107 height: height .value ,
104108 y: height .value ,
105109 })
106- push (' y' , 0 , motionProperties , { type: ' tween' , easings: ' easeInOut' , bounce: 0 , duration: 300 })
110+ push (' y' , 0 , motionProperties , {
111+ type: ' tween' ,
112+ easings: ' easeInOut' ,
113+ bounce: 0 ,
114+ duration: props .duration ,
115+ })
107116 showSheet .value = true
108117 isWindowScrollLocked .value = true
109118 isWindowRootScrollLocked .value = true
@@ -116,14 +125,18 @@ const open = () => {
116125 emit (' opened' )
117126 activate ()
118127 }
119- }, 300 )
128+ }, props . duration )
120129 }
121130}
122131// Close sheet method
123132const close = () => {
124133 if (! sheet .value ) return
125134
126- push (' y' , sheetHeight .value , motionProperties , { type: ' tween' , bounce: 0 , duration: 300 })
135+ push (' y' , sheetHeight .value , motionProperties , {
136+ type: ' tween' ,
137+ bounce: 0 ,
138+ duration: props .duration ,
139+ })
127140
128141 showSheet .value = false
129142 isWindowScrollLocked .value = false
@@ -139,7 +152,7 @@ const close = () => {
139152 if (motionValues .value .y ! .get () - sheetHeight .value < 0.1 ) {
140153 emit (' closed' )
141154 }
142- }, 300 )
155+ }, props . duration )
143156}
144157
145158// Backdrop click handler
@@ -160,7 +173,7 @@ const snapToPoint = (snapPoint: number) => {
160173 type: ' tween' ,
161174 easings: ' easeInOut' ,
162175 bounce: 0 ,
163- duration: 300 ,
176+ duration: props . duration ,
164177 })
165178}
166179
@@ -212,7 +225,7 @@ const handleDragEnd: Handler<'drag', PointerEvent> | undefined = () => {
212225 type: ' tween' ,
213226 easings: ' easeInOut' ,
214227 bounce: 0 ,
215- duration: 300 ,
228+ duration: props . duration ,
216229 })
217230
218231 if (translateY .value === height .value ) {
@@ -225,7 +238,7 @@ const handleDragEnd: Handler<'drag', PointerEvent> | undefined = () => {
225238 type: ' tween' ,
226239 easings: ' easeInOut' ,
227240 bounce: 0 ,
228- duration: 300 ,
241+ duration: props . duration ,
229242 })
230243}
231244
@@ -468,7 +481,7 @@ defineExpose({ open, close, snapToPoint })
468481 pointer-events : all ;
469482 position : fixed ;
470483 right : 0 ;
471- transition : visibility 300 ms ease-in-out ;
484+ transition : v-bind(transitionVisibility) ;
472485 visibility : hidden ;
473486 width : 100% ;
474487 will-change : height;
@@ -535,7 +548,7 @@ defineExpose({ open, close, snapToPoint })
535548
536549.fade-enter-active ,
537550.fade-leave-active {
538- transition : opacity 300 ms ease ;
551+ transition : v-bind(transitionOpacity) ;
539552}
540553
541554.fade-enter-from ,
0 commit comments