S
S
Sergey Miller2019-11-07 19:08:21
JavaScript
Sergey Miller, 2019-11-07 19:08:21

How to rewind custom html5 js video?

I am making a video player with js.

Did everything except rewind. I can not figure out how to rewind the video at all. There is an idea when mousemove on the < progress > element to find the distance (cursor coordinates) from the beginning of < progress > to the cursor itself and when clicking, change the cuurentTime of the video to this value. But I can't figure out how to find these coordinates starting from the element . e.pageX works from the beginning of the document or not?

var mouseX = Math.floor(e.pageX - progressBar.offsetLeft);


so returns incomprehensible coordinates, exactly NOT from the left edge of the progress edge and to the cursor

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pashenka, 2019-11-08
@like-a-boss

Yuzay e.clientX is x relative to the viewport. element.getBoundingClientRect()returns the coordinates of the element also relative to the viewport. Good luck.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question