Skip to content

Instantly share code, notes, and snippets.

@Spellhammer
Last active Apr 20, 2022
Embed
What would you like to do?
Book landing page video code.
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