update touchmove event

This commit is contained in:
Harvey committed 2022-04-26 17:50:17 +08:00
1 parent 49aedb0026
commit 3a3c21e059
3 files changed
+17 -11

No files matched your search

+8 -5
View File
@@ -25,11 +25,14 @@ export default function gestureInit(art, events) {
});
events.proxy($video, 'touchmove', (event) => {
if (event.touches.length === 1 && isDroging && art.duration) {
const widthDiff = event.touches[0].clientX - startX;
const proportion = clamp(widthDiff / $video.clientWidth, -1, 1);
currentTime = clamp(art.currentTime + art.duration * proportion, 0, art.duration);
notice.show = `${secondToTime(currentTime)} / ${secondToTime(art.duration)}`;
if (event.touches.length === 1 && isDroging) {
const { clientX } = event.touches[0];
const ratioX = clamp((clientX - startX) / $video.clientWidth, -1, 1);
if (art.duration) {
currentTime = clamp(art.currentTime + art.duration * ratioX, 0, art.duration);
notice.show = `${secondToTime(currentTime)} / ${secondToTime(art.duration)}`;
}
}
});