|
1 |
| -import { computed, ref, watch } from 'vue' |
| 1 | +import { computed, ref, watch, watchEffect } from 'vue' |
2 | 2 | import type { ComponentPublicInstance, Ref } from 'vue'
|
3 | 3 | import { dampenValue, getTranslateY, reset, set } from './helpers'
|
4 | 4 | import { TRANSITIONS, VELOCITY_THRESHOLD } from './constants'
|
@@ -423,6 +423,17 @@ export function useDrawer(props: UseDrawerProps & DialogEmitHandlers): DrawerRoo
|
423 | 423 | }, TRANSITIONS.DURATION * 1000) // seconds to ms
|
424 | 424 | }
|
425 | 425 |
|
| 426 | + watchEffect(() => { |
| 427 | + if (!isOpen.value && shouldScaleBackground.value) { |
| 428 | + // Can't use `onAnimationEnd` as the component will be invisible by then |
| 429 | + const id = setTimeout(() => { |
| 430 | + reset(document.body); |
| 431 | + }, 200); |
| 432 | + |
| 433 | + return () => clearTimeout(id); |
| 434 | + } |
| 435 | + }) |
| 436 | + |
426 | 437 | function onRelease(event: PointerEvent) {
|
427 | 438 | if (!isDragging.value || !drawerRef.value)
|
428 | 439 | return
|
@@ -519,6 +530,11 @@ export function useDrawer(props: UseDrawerProps & DialogEmitHandlers): DrawerRoo
|
519 | 530 | return
|
520 | 531 |
|
521 | 532 | if (open) {
|
| 533 | + // setting original styles initially |
| 534 | + set(document.body, { |
| 535 | + background: document.body.style.backgroundColor || document.body.style.background, |
| 536 | + }); |
| 537 | + // setting body styles, with cache ignored, so that we can get correct original styles in reset |
522 | 538 | set(
|
523 | 539 | document.body,
|
524 | 540 | {
|
|
0 commit comments