ソースを参照

解决safari浏览器scrollWidth会变化, 谱面移动过程中的兼容性问题

黄琪勇 1 年間 前
コミット
bb55fa112d
1 ファイル変更6 行追加3 行削除
  1. 6 3
      src/state.ts

+ 6 - 3
src/state.ts

@@ -1642,9 +1642,12 @@ watch(
       // 当在播放中暂停 执行这个方法
       if (!state.playEnd && state.playState === "paused") {
         moveTranslateXNum(0)
-        const scrollLeft = smoothAnimationState.osdmScrollDom!.scrollLeft
-        smoothAnimationState.osdmScrollDom!.scrollLeft = scrollLeft + smoothAnimationState.translateXNum
-        smoothAnimationState.translateXNum = 0
+        // 因为safari浏览器scrollWidth的值一直变化,scrollLeft + smoothAnimationState.translateXNum 为最大宽度的时候,实际上scrollLeft滚不到最大宽度,所以在下一帧处理滚动,能滚动到最大滚动位置
+        requestAnimationFrame(() => {
+          const scrollLeft = smoothAnimationState.osdmScrollDom!.scrollLeft
+          smoothAnimationState.osdmScrollDom!.scrollLeft = scrollLeft + smoothAnimationState.translateXNum
+          smoothAnimationState.translateXNum = 0
+        });
       }
     }
   }