|
1 | 1 | import { computed, ref, watch, watchEffect } from 'vue'
|
2 | 2 | import type { ComponentPublicInstance, Ref } from 'vue'
|
| 3 | +import { isClient } from '@vueuse/core' |
3 | 4 | import { dampenValue, getTranslateY, reset, set } from './helpers'
|
4 | 5 | import { TRANSITIONS, VELOCITY_THRESHOLD } from './constants'
|
5 | 6 | import { useSnapPoints } from './useSnapPoints'
|
@@ -195,9 +196,8 @@ export function useDrawer(props: UseDrawerProps & DialogEmitHandlers): DrawerRoo
|
195 | 196 | const swipeAmount = drawerRef.value ? getTranslateY(drawerRef.value.$el) : null
|
196 | 197 | const date = new Date()
|
197 | 198 |
|
198 |
| - if (element.hasAttribute('data-vaul-no-drag') || element.closest('[data-vaul-no-drag]')) { |
199 |
| - return false; |
200 |
| - } |
| 199 | + if (element.hasAttribute('data-vaul-no-drag') || element.closest('[data-vaul-no-drag]')) |
| 200 | + return false |
201 | 201 |
|
202 | 202 | // Allow scrolling when animating
|
203 | 203 | if (openTime.value && date.getTime() - openTime.value.getTime() < 500)
|
@@ -424,13 +424,13 @@ export function useDrawer(props: UseDrawerProps & DialogEmitHandlers): DrawerRoo
|
424 | 424 | }
|
425 | 425 |
|
426 | 426 | watchEffect(() => {
|
427 |
| - if (!isOpen.value && shouldScaleBackground.value) { |
| 427 | + if (!isOpen.value && shouldScaleBackground.value && isClient) { |
428 | 428 | // Can't use `onAnimationEnd` as the component will be invisible by then
|
429 | 429 | const id = setTimeout(() => {
|
430 |
| - reset(document.body); |
431 |
| - }, 200); |
| 430 | + reset(document.body) |
| 431 | + }, 200) |
432 | 432 |
|
433 |
| - return () => clearTimeout(id); |
| 433 | + return () => clearTimeout(id) |
434 | 434 | }
|
435 | 435 | })
|
436 | 436 |
|
@@ -533,7 +533,7 @@ export function useDrawer(props: UseDrawerProps & DialogEmitHandlers): DrawerRoo
|
533 | 533 | // setting original styles initially
|
534 | 534 | set(document.body, {
|
535 | 535 | background: document.body.style.backgroundColor || document.body.style.background,
|
536 |
| - }); |
| 536 | + }) |
537 | 537 | // setting body styles, with cache ignored, so that we can get correct original styles in reset
|
538 | 538 | set(
|
539 | 539 | document.body,
|
|
0 commit comments