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

Since V2 classes often don't get added on scroll #74

Open
andre-lergier opened this issue Jul 29, 2020 · 2 comments
Open

Since V2 classes often don't get added on scroll #74

andre-lergier opened this issue Jul 29, 2020 · 2 comments

Comments

@andre-lergier
Copy link

Since Version 2 unfortunately the plugin doesn't work very reliable anymore.

With the following code the plugin adds the class to the elements which are already in the viewport on page load.
While scrolling, the defined class gets added only very rarely to appearing elements - most of the time never. In my case this means, that the elements just never show up, what's a huge problem.

import ViewportChecker from 'viewport-checker';

document.addEventListener('DOMContentLoaded', () => {
  const vpc = new ViewportChecker('[data-in-vp-animation]', {
    classToAdd: 'in-vp',
    removeClassAfterAnimation: false,
    offset: `${10}%`,
  });

  vpc.attach();
});

If I change back to Version 1 using jQuery, everything works as expected:

import $ from 'jquery';
import 'jquery-viewport-checker';

document.addEventListener('DOMContentLoaded', () => {
  $('[data-in-vp-animation]').viewportChecker({
    classToAdd: 'in-vp',
    removeClassAfterAnimation: false,
    offset: `${10}%`,
  });
});
@martinsnajdr
Copy link

I have the same problem.

@Tropicalista
Copy link

Same here.

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

3 participants