Created
September 26, 2021 11:32
-
-
Save smpnjn/1dbd3a22e80d3dd2bccab397e2a7ecb2 to your computer and use it in GitHub Desktop.
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('.button').forEach(function(item) { | |
// Add on mouseenter | |
item.addEventListener('mouseenter', function(e) { | |
calculateAngle(e, this.querySelector('span'), this); | |
}); | |
// Add on mousemove | |
item.addEventListener('mousemove', function(e) { | |
calculateAngle(e, this.querySelector('span'), this); | |
}); | |
// Reset everything on mouse leave | |
item.addEventListener('mouseleave', function(e) { | |
let dropShadowColor = `rgba(0, 0, 0, 0.3)` | |
if(item.getAttribute('data-filter-color') !== null) { | |
dropShadowColor = item.getAttribute('data-filter-color') | |
} | |
item.querySelector('span').style.transform = `rotateY(0deg) rotateX(0deg) scale(1)`; | |
item.querySelector('span').style.filter = `drop-shadow(0 10px 15px ${dropShadowColor})`; | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment