-
-
Save Spellhammer/e1e1881866598e831e3901963993f80d to your computer and use it in GitHub Desktop.
Book landing page video code.
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
document.querySelectorAll('.mover').forEach( mover => { | |
if( window.angular ) return; | |
window.addEventListener('mousemove', (e) => { | |
if( !calculating ) { | |
var calculating = setTimeout( () => { | |
var divisor = mover.getAttribute('speed') ?? 32; | |
var windowMouseX = (e.clientX - (document.documentElement.clientWidth / 2)); | |
var windowMouseY = (e.clientY - (document.documentElement.clientHeight / 2)); | |
var computedCSS = ''; | |
var translateX = (windowMouseX / divisor) * -1; | |
var translateY = (windowMouseY / divisor) * -1; | |
computedCSS += 'transform: translateX(' + translateX + 'px) translateY(' + translateY + 'px);'; | |
mover.style.cssText = computedCSS; | |
clearTimeout(calculating); | |
}, 100); | |
} | |
}) | |
}) | |
window.addEventListener('scroll', () => { | |
if( window.angular ) return; | |
document.querySelectorAll('.spinner').forEach( spinner => { | |
spinner.style.cssText = 'transform: rotate(' + (-80 + (window.scrollY / 16)) + 'deg)'; | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment