Visitar URL original
The last half! by LHJE · Pull Request #5 · LHJE/JavaScript30 · GitHub
Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update 28 with logic from tutorial
  • Loading branch information
LHJE committed Jul 7, 2021
commit 8b3162f7802a29a60bcf5f8044323244c09b5e58
17 changes: 17 additions & 0 deletions 28 - Video Speed Controller/index-START.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,23 @@
</div>

<script>

const speed = document.querySelector('.speed');
const bar = speed.querySelector('.speed-bar');
const video = document.querySelector('.flex');

speed.addEventListener('mousemove', function(e) {
const y = e.pageY - this.offsetTop;
const percent = y / this.offsetHeight;
const min = 0.4;
const max = 4;
const height = Math.round(percent * 100) + '%';
const playbackRate = percent * (max - min) + min;
bar.style.height = height;
bar.textContent = playbackRate.toFixed(2) + 'x';
video.playbackRate = playbackRate;
});

</script>
</body>
</html>