Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative strategy for not conflicting with previous animations... #17

Open
danielbodart opened this issue Sep 27, 2020 · 0 comments
Open

Comments

@danielbodart
Copy link

I have come up with a simple alternative strategy that allows Sentinel to not conflict with previously defined animations: Just add a data attribute after the event fires and then make the animation use a negative attribute selector.

CSS

.some.selector.you.are.watching:not([data-sentinal-watched]) {
  animation: 0.0001s sentinal_watch;
}

Javascript

document.addEventListener('animationstart', ev => {
  if(ev.animationName === 'sentinal_watch') {
    ev.target.setAttribute('data-sentinal-watched', '');
  } 
});

Link to a CodePen example: https://codepen.io/danielbodart/pen/MWyxNQY

I don't think it's perfect as you will probably have a flicker as the JS will take time to run but maybe it's better?

@danielbodart danielbodart changed the title Alternative strategy for not conflicting with animation names... Alternative strategy for not conflicting with previous animations... Sep 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant