瀏覽代碼

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

shaojing 6 年之前
父節點
當前提交
945ef88885
共有 2 個文件被更改,包括 10 次插入6 次删除
  1. 1
    0
      package.json
  2. 9
    6
      src/video/api.js

+ 1
- 0
package.json 查看文件

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

+ 9
- 6
src/video/api.js 查看文件

@@ -5,12 +5,15 @@
5 5
  * set. To be primarily used in `mapVideoElToProps`.
6 6
  */
7 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