Last active
April 4, 2018 00:11
-
-
Save eduzappa18/1390474096b960322def052376595ae9 to your computer and use it in GitHub Desktop.
rotate youtube videos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function() { | |
let vid = document.querySelector('video'); | |
let scale, style; | |
if (vid) { | |
if (vid.toggle === undefined) { | |
vid.toggle = true; | |
} | |
if (vid.toggle) { | |
scale = vid.videoHeight/vid.videoWidth; | |
} | |
else { | |
scale = 1; | |
} | |
vid.toggle = !vid.toggle; | |
if (!vid.dg) { | |
vid.dg = 90; | |
} | |
else { | |
vid.dg += 90; | |
} | |
style = 'transform:rotate(' + vid.dg + 'deg) scale(' + scale + ');transition-duration:0.25s;position:absolute;width:100%;height:100%;'; | |
vid.parentNode.style = style; | |
vid.addEventListener('ended', function (e) { | |
vid.parentNode.style = ''; | |
}, false); | |
} else { | |
alert('no video element found.'); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment