File tree Expand file tree Collapse file tree 2 files changed +51
-1
lines changed Expand file tree Collapse file tree 2 files changed +51
-1
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,11 @@ export default {
1616 projectName : 'react-navigation.github.io' ,
1717 onBrokenAnchors : 'throw' ,
1818 onBrokenMarkdownLinks : 'throw' ,
19- scripts : [ '/js/snack-helpers.js' , '/js/toc-fixes.js' ] ,
19+ scripts : [
20+ '/js/snack-helpers.js' ,
21+ '/js/toc-fixes.js' ,
22+ '/js/video-playback.js' ,
23+ ] ,
2024 themeConfig : {
2125 colorMode : {
2226 defaultMode : 'light' ,
Original file line number Diff line number Diff line change 1+ function fadeInOnLoad ( video ) {
2+ if ( video . readyState >= 3 ) {
3+ video . style . transition = 'opacity 1s' ;
4+ video . style . opacity = '1' ;
5+ } else {
6+ video . style . transition = 'opacity 1s' ;
7+ video . style . opacity = '0' ;
8+
9+ video . addEventListener ( 'canplaythrough' , ( ) => {
10+ video . style . opacity = '1' ;
11+ } ) ;
12+ }
13+ }
14+
15+ document . addEventListener ( 'DOMContentLoaded' , ( ) => {
16+ const observer = new MutationObserver ( ( ) => {
17+ const videos = document . querySelectorAll ( 'video' ) ;
18+
19+ videos . forEach ( ( video ) => {
20+ if ( video . dataset . seen ) {
21+ return ;
22+ }
23+
24+ video . dataset . seen = true ;
25+
26+ if ( video . hasAttribute ( 'playsinline' ) ) {
27+ video . addEventListener ( 'click' , ( ) => {
28+ if ( video . paused ) {
29+ video . play ( ) ;
30+ } else {
31+ video . pause ( ) ;
32+ }
33+ } ) ;
34+ }
35+
36+ fadeInOnLoad ( video ) ;
37+ } ) ;
38+ } ) ;
39+
40+ observer . observe ( document . documentElement , {
41+ childList : true ,
42+ subtree : true ,
43+ } ) ;
44+ } ) ;
45+
46+ console . log ( 'Video playback script loaded' ) ;
You can’t perform that action at this time.
0 commit comments