Skip to content

Commit 1027dc4

Browse files
Finalizando o dia 28
1 parent 5330417 commit 1027dc4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

28-VideoSpeedController/finish.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,23 @@
1515
</div>
1616

1717
<script>
18+
const speed = document.querySelector('.speed');
19+
const bar = speed.querySelector('.speed-bar');
20+
const video = document.querySelector('.flex');
21+
22+
function handleMove(event) {
23+
const pageY = event.pageY - this.offsetTop;
24+
const percent = pageY / this.offsetHeight;
25+
const min = 0.5;
26+
const max = 4;
27+
const height = `${Math.round(percent * 100)}%`;
28+
const playbackRate = ((percent * (max - min)) + min);
29+
bar.style.height = height;
30+
bar.textContent = `${playbackRate.toFixed(2)}x`;
31+
video.playbackRate = playbackRate;
32+
}
33+
34+
speed.addEventListener('mousemove', handleMove);
1835
</script>
1936
</body>
2037
</html>

0 commit comments

Comments
 (0)