Skip to content

Commit 939cff1

Browse files
committed
Completed lesson 28
Drunk Wes. Cracked out Wes. Wasted Wes. Hyper Wes!
1 parent 91c8865 commit 939cff1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

28 - Video Speed Controller/index-START.html

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

1717
<script>
18+
const speed = document.querySelector('.speed');
19+
const bar = document.querySelector('.speed-bar');
20+
const video = document.querySelector('.flex');
21+
22+
speed.addEventListener('mousemove', function(e) {
23+
const y = e.pageY - this.offsetTop;
24+
const percent = y / this.offsetHeight;
25+
const min = 0.4;
26+
const max = 4;
27+
const height = Math.round(percent * 100) + '%';
28+
const playbackRate = percent * (max - min) + min;
29+
bar.textContent = playbackRate.toFixed(1) + 'x';
30+
bar.style.height = height;
31+
32+
video.playbackRate = playbackRate;
33+
});
1834
</script>
1935
</body>
2036
</html>

0 commit comments

Comments
 (0)