We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0715834 commit 025919eCopy full SHA for 025919e
1 file changed
src/theme/CodeBlock/VideoPlayer/VideoModal/index.tsx
@@ -2,6 +2,7 @@ import React, {
2
useCallback,
3
useEffect,
4
useRef,
5
+ useLayoutEffect,
6
useState,
7
} from 'react'
8
import Draggable, {
@@ -56,6 +57,26 @@ function VideoModal({
56
57
onTimeChange,
58
])
59
60
+ useLayoutEffect(() => {
61
+ if (!draggableContainerRef.current) return
62
+
63
+ const observer = new IntersectionObserver(([entry]) => {
64
+ if (!entry) return
65
+ if (!entry.isIntersecting) {
66
+ changePosition({ x: 0, y: 0 })
67
+ }
68
+ })
69
70
+ observer.observe(draggableContainerRef.current)
71
+ return () => {
72
+ observer.disconnect()
73
74
+ }, [
75
+ position,
76
+ changePosition,
77
+ draggableContainerRef,
78
+ ])
79
80
const stopDragging = useCallback<DraggableEventHandler>((_, data) => {
81
setIsDragged(false)
82
0 commit comments