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

Support individual target animation repeat #45

Closed
allaire opened this issue Mar 10, 2020 · 2 comments · Fixed by #58
Closed

Support individual target animation repeat #45

allaire opened this issue Mar 10, 2020 · 2 comments · Fixed by #58

Comments

@allaire
Copy link

allaire commented Mar 10, 2020

I would like to be able to have animations running once on almost every elements, except some. Currently, the once option is global. What about supporting an individual option (via data attributes) for specific elements?

Something like <div data-sal="fade" data-sal-repeat></div>

const onIntersection = (entries, observer) => {
  entries.forEach(entry => {
    if (entry.intersectionRatio >= options.threshold) {
      animate(entry);

      if (options.once && entry.target.dataset.salRepeat === undefined) {
        observer.unobserve(entry.target);
      }
    } else if (!options.once || entry.target.dataset.salRepeat !== undefined) {
      reverse(entry);
    }
  });
};
@allaire allaire changed the title Add "inview" class Support individual target animation repeat Mar 10, 2020
@mciastek
Copy link
Owner

mciastek commented Mar 14, 2020

I like this enhancement 👍 Would you like to create a PR with it?

@mciastek mciastek linked a pull request May 25, 2020 that will close this issue
@jesserosenfield
Copy link

Or alternatively [data-sal-once] HTML attribute

Thanks for the amazing plugin!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants