This repository has been archived by the owner on Jan 2, 2024. It is now read-only.
Pause auto play on hover v2 - electric boogaloo #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is revised implementation of #4 with 4536% more sexy.
Feature
Pause gallery autoplay whilst an item is being hovered over as one would expect from a tradition javascript based solution.
How?
CSS3 animation module to the rescue, more specifically
animation-play-state: paused;
.But wait
There's a cavet though! As I alluded to in my original implementation
The current implementation defines a single animation that is applied to all gallery items with successive delays (hawt!). As noted above this doesn't play nice if you happen to hover the gallery before every animation has begun to play atleast once.
To work around this initially I programmatically generated a new animation for each item. This works as expected but was messy.
The solution
To avoid the excessive increase in complexity, and generated file size of my original approach I wanted to find a way to get delays and play-state to play nice.
Viola! By reversing the animating I could instead use negative delays. This means all the animations have technically begun immediately so play-state can now be utilised.