Skip to content

Instantly share code, notes, and snippets.

@twosky2000
Created September 23, 2018 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twosky2000/cae005296791af6cf1128867087e29f4 to your computer and use it in GitHub Desktop.
Save twosky2000/cae005296791af6cf1128867087e29f4 to your computer and use it in GitHub Desktop.
Simple Script that reads if the mouse is down speed is adjust, jumps back when let go
var myvid = document.getElementsByTagName('video')[0];
var mouseDown = 0;
document.body.onmousedown = function() {
mouseDown = 1;
}
document.body.onmouseup = function() {
mouseDown = 0;
myvid.playbackRate = 1;
myvid.currentTime -= 5;
}
document.onmousemove = handleMouseMove;
function handleMouseMove(event) {
if(mouseDown){
var height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
speed = event.pageY/height;
console.log(1+(speed))
myvid.playbackRate = 1+(speed);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment