Skip to content

Commit d4fa63d

Browse files
authored
Merge pull request #18 from rosmis/rosmis-add-snapped-event
feat(snap): added snapped emit event
2 parents 72859a9 + 823d8d4 commit d4fa63d

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ Assuming there is `const bottomSheet = ref()`
162162
| dragging-up | Emitted when user drags sheet upward | - |
163163
| dragging-down | Emitted when user drags sheet downward | - |
164164
| instinctHeight | Emitted when content height changes | height (number) |
165+
| snapped | Emitted when sheet finishes snapping | snapPointIndex (number) |
165166

166167
## Acknowledgments
167168

bun.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
},
2424
"packages/vue-spring-bottom-sheet": {
2525
"name": "@douxcode/vue-spring-bottom-sheet",
26-
"version": "2.0.4",
26+
"version": "2.1.0",
2727
"dependencies": {
2828
"@vueuse/core": "^13.0.0",
2929
"@vueuse/integrations": "^13.0.0",

packages/vue-spring-bottom-sheet/src/BottomSheet.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const emit = defineEmits<{
2626
(e: 'ready'): void
2727
(e: 'dragging-up'): void
2828
(e: 'dragging-down'): void
29+
(e: 'snapped', snapPointIndex?: number): void
2930
(e: 'instinctHeight', instinctHeight: number): void
3031
(e: 'update:modelValue'): void
3132
}>()
@@ -243,6 +244,7 @@ const snapToPoint = (index: number) => {
243244
controls = animate(heightValue, height.value, {
244245
duration: props.duration / 1000,
245246
ease: 'easeInOut',
247+
onComplete: () => emit('snapped', snapPointsRef.value.indexOf(snapPointsRef.value[index])),
246248
})
247249
}
248250
@@ -332,6 +334,11 @@ const handlePanEnd = () => {
332334
controls = animate(heightValue, height.value, {
333335
duration: props.duration / 1000,
334336
ease: 'easeInOut',
337+
onComplete: () =>
338+
emit(
339+
'snapped',
340+
snapPointsRef.value.indexOf(snapPointsRef.value[closestSnapPointIndex.value]),
341+
),
335342
})
336343
controls = animate(translateYValue, 0, {
337344
duration: props.duration / 1000,

0 commit comments

Comments
 (0)