File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
src/theme/CodeBlock/VideoPlayer/VideoModal Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import React, {
22 useCallback ,
33 useEffect ,
44 useRef ,
5+ useLayoutEffect ,
56 useState ,
67} from 'react'
78import Draggable , {
@@ -56,6 +57,26 @@ function VideoModal({
5657 onTimeChange ,
5758 ] )
5859
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+
5980 const stopDragging = useCallback < DraggableEventHandler > ( ( _ , data ) => {
6081 setIsDragged ( false )
6182
You can’t perform that action at this time.
0 commit comments