DeltaFrog Posted April 28, 2022 Share Posted April 28, 2022 Hi All, Does anyone know how to target the visible part of a .png with a listener instead of its containing div? I want the mouse over function to run when the mouse is over the visible part of the .png instead of the square div its in. I tried this path and it worked but the transparent part of the png still activates the listener. Id also like to apply a glow to the PNG so I don't have to swap in another image. Can GSAP do glows? Thoughts? document.querySelector("#largeShipID > img").addEventListener('click', function(){ See the Pen QWaepXJ by deltafrogcraft (@deltafrogcraft) on CodePen Link to comment Share on other sites More sharing options...
Solution PointC Posted April 29, 2022 Solution Share Posted April 29, 2022 You could drop it into an SVG and use a clip-path. (Pointer events will only register on the revealed area.) Then add a separate glow image. I'd do something like this: See the Pen QWQLGqY by PointC (@PointC) on CodePen Happy tweening. 4 Link to comment Share on other sites More sharing options...
DeltaFrog Posted April 29, 2022 Author Share Posted April 29, 2022 AMAZING! Thanks Craig! 1 Link to comment Share on other sites More sharing options...
PointC Posted April 29, 2022 Share Posted April 29, 2022 Happy to help. That was a fun one. Just FYI - I converted the .png files to .webp which resulted in a lot smaller file size. You don't have to do that, but this is an excellent place for quick conversions. https://cloudconvert.com/ Happy tweening. 2 Link to comment Share on other sites More sharing options...
DeltaFrog Posted April 29, 2022 Author Share Posted April 29, 2022 I will start exporting .webp, thanks Craig! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now