bouncing-balls | Bouncing balls simulation using plain JavaScript | Canvas library
kandi X-RAY | bouncing-balls Summary
kandi X-RAY | bouncing-balls Summary
Bouncing balls simulation using plain JavaScript
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of bouncing-balls
bouncing-balls Key Features
bouncing-balls Examples and Code Snippets
Community Discussions
Trending Discussions on bouncing-balls
QUESTION
I have two play-once GIFs similar to the ones attached. I'd like to have the first GIF replace the original PNG upon mouseover, but even if someone removes the cursor from the image, finish playing the GIF so the last frame is in place before the mouseout GIF, which is the reverse of the previous one, replaces it and plays. I'd also like the original PNG to replace the mouseout GIF when it is finished playing, too. So, original > mouseover long enough to finish playing > mouseout long enough to finish playing > original.
I tried a javascript I found on here, and it worked to replace the images, but the mouseover GIF kept playing every now and again (even while the cursor was still on it) even though it is a play-once GIF (the script must have kept refreshing the GIF or something).
I'd keep the script in an external file as opposed to inline, of course. I know enough javascript to edit scripts, but not write them from scratch. jQuery is available, if needed.
Thanks for your help!
mouseover GIF mouseout GIF original PNG
ETA: This is what I tried before, although this wasn't the final version of it since I was trying different things on that site that lets you try scripts on, and I think I had the timing set to 2888. I don't have the other script since I didn't save it:
...ANSWER
Answered 2021-Jun-06 at 06:06I guessed the animations to last about 3 seconds, but you can change that. Using setTimeout
and a couple boolean values, we can delay the mouse on or off operation and queue up the next one. I also preload the images at the beginning to smooth out any loading flickers.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install bouncing-balls
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page