Skip to content

Commit be5612f

Browse files
committed
feat: allow user to interrupt animation;
feat: emit maxHeight change on window height change; fix: early drag lock before overflow; refactor: added 'remeda' and small changes for improved clarity; chore(playground): update testing playground with new examples;
1 parent 9ebf84c commit be5612f

File tree

13 files changed

+137
-142
lines changed

13 files changed

+137
-142
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ For Nuxt 3, just wrap component in `<ClientOnly>`
7676

7777
```css
7878
--vsbs-backdrop-bg: rgba(0, 0, 0, 0.5);
79-
--vsbs-shadow-color: hsla(0, 0%, 35%, 0.2);
79+
--vsbs-shadow-color: rgba(89, 89, 89, 0.2);
8080
--vsbs-background: #fff;
8181
--vsbs-border-radius: 16px;
8282
--vsbs-max-width: 640px;

bun.lockb

705 Bytes
Binary file not shown.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"url": "https://github.com/megaarmos/vue-spring-bottom-sheet/issues"
3333
},
3434
"private": false,
35-
"version": "1.0.8",
35+
"version": "1.1.0",
3636
"type": "module",
3737
"exports": {
3838
".": {
@@ -63,6 +63,7 @@
6363
"@vueuse/integrations": "^12.0.0",
6464
"@vueuse/motion": "^2.2.6",
6565
"focus-trap": "^7",
66+
"remeda": "^2.19.0",
6667
"vue": "^3.5.13"
6768
},
6869
"devDependencies": {

playground/nuxt/pages/blocking.vue

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,39 @@ import { ref, version } from 'vue'
44
import BottomSheet from 'vue-spring-bottom-sheet'
55
import 'vue-spring-bottom-sheet/dist/style.css'
66
7-
const myBottomSheet = ref<InstanceType<typeof BottomSheet>>()
7+
const bottomSheet = ref<InstanceType<typeof BottomSheet>>()
88
const open = ref(false)
99
const maxHeight = ref(0)
10-
const minHeight = ref(0)
11-
12-
const expandOnContentDrag = ref(true)
1310
1411
const toggle = () => {
1512
open.value = !open.value
1613
1714
if (open.value) {
18-
myBottomSheet.value?.open()
15+
bottomSheet.value?.open()
1916
} else {
20-
myBottomSheet.value?.close()
17+
bottomSheet.value?.close()
2118
}
2219
}
2320
</script>
2421

2522
<template>
2623
<div class="content">
27-
<button class="btn btn-primary" type="button" @click="toggle">{{ open ? 'Close' : 'Open' }} bottom sheet</button>
24+
<button type="button" @click="toggle">{{ open ? 'Close' : 'Open' }} bottom sheet</button>
2825
<p>vue js: {{ version }}</p>
2926
</div>
3027
<ClientOnly>
3128
<BottomSheet
32-
ref="myBottomSheet"
29+
ref="bottomSheet"
3330
:blocking="false"
34-
:can-overlay-close="true"
35-
:can-swipe-close="true"
36-
:expand-on-content-drag="expandOnContentDrag"
3731
:snap-points="[maxHeight / 4, maxHeight / 1.5]"
38-
@min-height="(n) => (minHeight = n)"
32+
@closed="open = false"
33+
@ready="toggle()"
3934
@max-height="(n) => (maxHeight = n)"
4035
>
4136
<template #header>
4237
<input type="text" placeholder="Search..." style="width: 100%; padding: 0.5rem; box-sizing: border-box" />
4338
</template>
44-
<p v-for="i in 3" :key="i">
39+
<p v-for="i in 3" class="mb-4" :key="i">
4540
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Iste aperiam, accusamus amet veniam officiis libero necessitatibus ipsum,
4641
reprehenderit eveniet neque ad delectus fugit!
4742
</p>

playground/nuxt/pages/index.vue

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,37 @@ import { ref, version } from 'vue'
44
import BottomSheet from 'vue-spring-bottom-sheet'
55
import 'vue-spring-bottom-sheet/dist/style.css'
66
7-
const myBottomSheet = ref<InstanceType<typeof BottomSheet>>()
7+
const bottomSheet = ref<InstanceType<typeof BottomSheet>>()
88
99
const open = () => {
10-
myBottomSheet.value?.open()
10+
bottomSheet.value?.open()
1111
}
1212
1313
const close = () => {
14-
myBottomSheet.value?.close()
14+
bottomSheet.value?.close()
1515
}
1616
</script>
1717

1818
<template>
1919
<div class="content">
20-
<button class="btn btn-primary" type="button" @click="open">Open bottom sheet</button>
20+
<button type="button" @click="open">Open bottom sheet</button>
2121
<p>vue js: {{ version }}</p>
2222
</div>
2323
<ClientOnly>
24-
<BottomSheet ref="myBottomSheet">
25-
<p v-for="i in 3" :key="i">
26-
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Iste aperiam, accusamus amet veniam officiis libero necessitatibus ipsum,
27-
reprehenderit eveniet neque ad delectus fugit!
24+
<BottomSheet ref="bottomSheet">
25+
<p class="mb-4">
26+
Lorem ipsum dolor sit amet consectetur adipisicing elit. Alias atque error dignissimos impedit iure facilis ipsam sit cum molestias,
27+
natus, cupiditate molestiae, id exercitationem eaque obcaecati a animi. Accusamus, pariatur.
2828
</p>
29-
<details>
30-
<summary>Epcot Center</summary>
31-
<p v-for="i in 5" :key="i">
32-
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Iste aperiam, accusamus amet veniam officiis libero necessitatibus
33-
ipsum, reprehenderit eveniet neque ad delectus fugit!
34-
</p>
29+
<details class="mb-4">
30+
<summary>Tap to expand</summary>
31+
<div class="py-4">
32+
<Placeholder class="h-8" />
33+
<p class="my-5">It adjusts its height based on the content.</p>
34+
<Placeholder class="h-8" />
35+
</div>
3536
</details>
36-
<template #footer>
37-
<button type="button" @click="close">Close bottom sheet</button>
38-
</template>
37+
<button type="button" class="mb-4" @click="close">Close bottom sheet</button>
3938
</BottomSheet>
4039
</ClientOnly>
4140
</template>

playground/nuxt/pages/snap.vue

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,32 @@ import { ref, version } from 'vue'
44
import BottomSheet from 'vue-spring-bottom-sheet'
55
import 'vue-spring-bottom-sheet/dist/style.css'
66
7-
const myBottomSheet = ref<InstanceType<typeof BottomSheet>>()
7+
const bottomSheet = ref<InstanceType<typeof BottomSheet>>()
88
const maxHeight = ref(0)
99
const minHeight = ref(0)
1010
1111
const expandOnContentDrag = ref(true)
1212
1313
const open = () => {
14-
myBottomSheet.value?.open()
14+
bottomSheet.value?.open()
1515
}
1616
1717
const snapToPoint = (snapPoint: number) => {
18-
myBottomSheet.value?.snapToPoint(snapPoint)
18+
bottomSheet.value?.snapToPoint(snapPoint)
1919
}
2020
</script>
2121

2222
<template>
2323
<div class="content">
24-
<button class="btn btn-primary" type="button" @click="open">Open bottom sheet</button>
24+
<button type="button" @click="open">Open bottom sheet</button>
2525
<p>vue js: {{ version }}</p>
2626
</div>
2727
<ClientOnly>
2828
<BottomSheet
29-
ref="myBottomSheet"
30-
:blocking="true"
31-
:can-overlay-close="true"
32-
:can-swipe-close="true"
29+
ref="bottomSheet"
30+
:can-swipe-close="false"
3331
:expand-on-content-drag="expandOnContentDrag"
34-
:snap-points="[maxHeight / 3, maxHeight / 1.5, maxHeight]"
32+
:snap-points="[maxHeight / 3, maxHeight / 1.5, maxHeight - 100]"
3533
@min-height="(n) => (minHeight = n)"
3634
@max-height="(n) => (maxHeight = n)"
3735
>

playground/nuxt/pages/sticky.vue

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,24 @@ import { ref, version } from 'vue'
44
import BottomSheet from 'vue-spring-bottom-sheet'
55
import 'vue-spring-bottom-sheet/dist/style.css'
66
7-
const myBottomSheet = ref<InstanceType<typeof BottomSheet>>()
8-
const maxHeight = ref(0)
9-
10-
const expandOnContentDrag = ref(true)
7+
const bottomSheet = ref<InstanceType<typeof BottomSheet>>()
118
129
const open = () => {
13-
myBottomSheet.value?.open()
10+
bottomSheet.value?.open()
1411
}
1512
1613
const close = () => {
17-
myBottomSheet.value?.close()
14+
bottomSheet.value?.close()
1815
}
1916
</script>
2017

2118
<template>
2219
<div class="content">
23-
<button class="btn btn-primary" type="button" @click="open">Open bottom sheet</button>
20+
<button type="button" @click="open">Open bottom sheet</button>
2421
<p>vue js: {{ version }}</p>
2522
</div>
2623
<ClientOnly>
27-
<BottomSheet
28-
ref="myBottomSheet"
29-
:blocking="true"
30-
:can-overlay-close="true"
31-
:can-swipe-close="true"
32-
:expand-on-content-drag="expandOnContentDrag"
33-
:snap-points="[maxHeight / 3, maxHeight / 1.5, maxHeight]"
34-
@max-height="(n) => (maxHeight = n)"
35-
>
24+
<BottomSheet ref="bottomSheet">
3625
<template #header>
3726
<h1 style="font-size: 24px; margin: 0; text-align: center">Header</h1>
3827
</template>

playground/vue/src/pages/blocking.vue

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,38 @@ import { ref, version } from 'vue'
44
import BottomSheet from 'vue-spring-bottom-sheet'
55
import 'vue-spring-bottom-sheet/dist/style.css'
66
7-
const myBottomSheet = ref<InstanceType<typeof BottomSheet>>()
7+
const bottomSheet = ref<InstanceType<typeof BottomSheet>>()
88
const open = ref(false)
99
const maxHeight = ref(0)
10-
const minHeight = ref(0)
11-
12-
const expandOnContentDrag = ref(true)
1310
1411
const toggle = () => {
1512
open.value = !open.value
1613
1714
if (open.value) {
18-
myBottomSheet.value?.open()
15+
bottomSheet.value?.open()
1916
} else {
20-
myBottomSheet.value?.close()
17+
bottomSheet.value?.close()
2118
}
2219
}
2320
</script>
2421

2522
<template>
2623
<div class="content">
27-
<button class="btn btn-primary" type="button" @click="toggle">{{ open ? 'Close' : 'Open' }} bottom sheet</button>
24+
<button type="button" @click="toggle">{{ open ? 'Close' : 'Open' }} bottom sheet</button>
2825
<p>vue js: {{ version }}</p>
2926
</div>
3027
<BottomSheet
31-
ref="myBottomSheet"
28+
ref="bottomSheet"
3229
:blocking="false"
33-
:can-overlay-close="true"
34-
:can-swipe-close="true"
35-
:expand-on-content-drag="expandOnContentDrag"
3630
:snap-points="[maxHeight / 4, maxHeight / 1.5]"
37-
@min-height="(n) => (minHeight = n)"
31+
@closed="open = false"
32+
@ready="toggle()"
3833
@max-height="(n) => (maxHeight = n)"
3934
>
4035
<template #header>
4136
<input type="text" placeholder="Search..." style="width: 100%; padding: 0.5rem; box-sizing: border-box" />
4237
</template>
43-
<p v-for="i in 3" :key="i">
38+
<p v-for="i in 3" class="mb-4" :key="i">
4439
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Iste aperiam, accusamus amet veniam officiis libero necessitatibus ipsum,
4540
reprehenderit eveniet neque ad delectus fugit!
4641
</p>

playground/vue/src/pages/index.vue

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,36 @@ import { ref, version } from 'vue'
44
import BottomSheet from 'vue-spring-bottom-sheet'
55
import 'vue-spring-bottom-sheet/dist/style.css'
66
7-
const myBottomSheet = ref<InstanceType<typeof BottomSheet>>()
7+
const bottomSheet = ref<InstanceType<typeof BottomSheet>>()
88
99
const open = () => {
10-
myBottomSheet.value?.open()
10+
bottomSheet.value?.open()
1111
}
1212
1313
const close = () => {
14-
myBottomSheet.value?.close()
14+
bottomSheet.value?.close()
1515
}
1616
</script>
1717

1818
<template>
1919
<div class="content">
20-
<button class="btn btn-primary" type="button" @click="open">Open bottom sheet</button>
20+
<button type="button" @click="open">Open bottom sheet</button>
2121
<p>vue js: {{ version }}</p>
2222
</div>
23-
<BottomSheet ref="myBottomSheet">
24-
<p v-for="i in 5" :key="i">
25-
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Iste aperiam, accusamus amet veniam officiis libero necessitatibus ipsum,
26-
reprehenderit eveniet neque ad delectus fugit!
23+
<BottomSheet ref="bottomSheet">
24+
<p class="mb-4">
25+
Lorem ipsum dolor sit amet consectetur adipisicing elit. Alias atque error dignissimos impedit iure facilis ipsam sit cum molestias,
26+
natus, cupiditate molestiae, id exercitationem eaque obcaecati a animi. Accusamus, pariatur.
2727
</p>
28-
<details>
29-
<summary>Epcot Center</summary>
30-
<p v-for="i in 5" :key="i">
31-
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Iste aperiam, accusamus amet veniam officiis libero necessitatibus ipsum,
32-
reprehenderit eveniet neque ad delectus fugit!
33-
</p>
28+
<details class="mb-4">
29+
<summary>Tap to expand</summary>
30+
<div class="py-4">
31+
<Placeholder class="h-8" />
32+
<p class="my-5">It adjusts its height based on the content.</p>
33+
<Placeholder class="h-8" />
34+
</div>
3435
</details>
35-
<template #footer>
36-
<button type="button" @click="close">Close bottom sheet</button>
37-
</template>
36+
<button type="button" class="mb-4" @click="close"> Close bottom sheet </button>
3837
</BottomSheet>
3938
</template>
4039

playground/vue/src/pages/snap.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,31 @@ import { ref, version } from 'vue'
44
import BottomSheet from 'vue-spring-bottom-sheet'
55
import 'vue-spring-bottom-sheet/dist/style.css'
66
7-
const myBottomSheet = ref<InstanceType<typeof BottomSheet>>()
7+
const bottomSheet = ref<InstanceType<typeof BottomSheet>>()
88
const maxHeight = ref(0)
99
const minHeight = ref(0)
1010
1111
const expandOnContentDrag = ref(true)
1212
1313
const open = () => {
14-
myBottomSheet.value?.open()
14+
bottomSheet.value?.open()
1515
}
1616
1717
const snapToPoint = (snapPoint: number) => {
18-
myBottomSheet.value?.snapToPoint(snapPoint)
18+
bottomSheet.value?.snapToPoint(snapPoint)
1919
}
2020
</script>
2121

2222
<template>
2323
<div class="content">
24-
<button class="btn btn-primary" type="button" @click="open">Open bottom sheet</button>
24+
<button type="button" @click="open">Open bottom sheet</button>
2525
<p>vue js: {{ version }}</p>
2626
</div>
2727
<BottomSheet
28-
ref="myBottomSheet"
28+
ref="bottomSheet"
2929
:blocking="true"
3030
:can-overlay-close="true"
31-
:can-swipe-close="true"
31+
:can-swipe-close="false"
3232
:expand-on-content-drag="expandOnContentDrag"
3333
:snap-points="[maxHeight / 3, maxHeight / 1.5, maxHeight]"
3434
@min-height="(n) => (minHeight = n)"

0 commit comments

Comments
 (0)