Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 監聽事件
- let mousedown = false;
- progress.addEventListener("click", scrub);
- // progress.addEventListener("mousemove", (e) => {
- // if (mousedown) {
- // scrub(e);
- // }
- // });
- // if mousedown is true, moves on running scrub(), if mousedown is false, it's not going to run the scrub
- progress.addEventListener("mousemove", (e) => mousedown && scrub(e));
- progress.addEventListener("mousedown", () => mousedown = true);
- progress.addEventListener("mouseup", () => mousedown = false);
- function scrub(e) {
- // console.log(e);
- const scrubTime = (e.offsetX / progress.offsetWidth) * video.duration;
- video.currentTime = scrubTime;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement