Browse Source

add npm-cmd: prepare & fix videoTitle toggle bug.

shaojing 6 years ago
parent
commit
945ef88885
2 changed files with 10 additions and 6 deletions
  1. 1
    0
      package.json
  2. 9
    6
      src/video/api.js

+ 1
- 0
package.json View File

13
     "i:demo": "npm run install:demo",
13
     "i:demo": "npm run install:demo",
14
     "test": "jest --env=jsdom",
14
     "test": "jest --env=jsdom",
15
     "test:watch": "npm run test -- --watch",
15
     "test:watch": "npm run test -- --watch",
16
+    "prepare": "npm run build",
16
     "build": "webpack --display-error-details",
17
     "build": "webpack --display-error-details",
17
     "build:demo": "cd demo && webpack",
18
     "build:demo": "cd demo && webpack",
18
     "deploy:demo": "node scripts/deploy:demo.js",
19
     "deploy:demo": "node scripts/deploy:demo.js",

+ 9
- 6
src/video/api.js View File

5
  * set. To be primarily used in `mapVideoElToProps`.
5
  * set. To be primarily used in `mapVideoElToProps`.
6
  */
6
  */
7
 export const togglePause = (videoEl, { paused }) => {
7
 export const togglePause = (videoEl, { paused }) => {
8
-    if (paused) {
9
-        videoEl.play();
10
-        document.querySelector("#videoTitle").style.display = 'none';
11
-    } else {
12
-        videoEl.pause();
13
-        document.querySelector("#videoTitle").style.display = '';
8
+    const videoTitleEl = document.getElementById("videoTitle")
9
+    if (videoTitleEl) {
10
+        if (paused) {
11
+            videoEl.play();
12
+            videoTitleEl.style.display = 'none';
13
+        } else {
14
+            videoEl.pause();
15
+            videoTitleEl.style.display = '';
16
+        }
14
     }
17
     }
15
 };
18
 };
16
 
19