File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,38 @@ export function VideoSlide({ slide, offset }: VideoSlideProps) {
113
113
}
114
114
} , [ offset , getOwnerDocument ] ) ;
115
115
116
+ React . useEffect ( ( ) => {
117
+ if ( offset === 0 ) {
118
+ let pip = false ;
119
+
120
+ const trackPiP = ( pipValue : boolean ) => ( event : Event ) => {
121
+ if ( event . target === videoRef . current ) {
122
+ pip = pipValue ;
123
+ freezeNavigation . current = pip ;
124
+ }
125
+ } ;
126
+
127
+ const onEnterPiP = trackPiP ( true ) ;
128
+ const onLeavePiP = trackPiP ( false ) ;
129
+
130
+ getOwnerDocument ( ) . addEventListener ( "enterpictureinpicture" , onEnterPiP ) ;
131
+ getOwnerDocument ( ) . addEventListener ( "leavepictureinpicture" , onLeavePiP ) ;
132
+
133
+ return ( ) => {
134
+ getOwnerDocument ( ) . removeEventListener ( "enterpictureinpicture" , onEnterPiP ) ;
135
+ getOwnerDocument ( ) . removeEventListener ( "leavepictureinpicture" , onLeavePiP ) ;
136
+
137
+ if ( pip ) {
138
+ freezeNavigation . current = false ;
139
+
140
+ getOwnerDocument ( )
141
+ . exitPictureInPicture ( )
142
+ . catch ( ( ) => { } ) ;
143
+ }
144
+ } ;
145
+ }
146
+ } , [ offset , getOwnerDocument ] ) ;
147
+
116
148
const { width, height, poster, sources } = slide ;
117
149
118
150
const scaleWidthAndHeight = ( ) => {
You can’t perform that action at this time.
0 commit comments