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

Animation trigger too early when using other script like "load more" cards #833

Open
Bammede opened this issue Sep 16, 2023 · 1 comment

Comments

@Bammede
Copy link

Bammede commented Sep 16, 2023

This is:

  • Bug

Specifications

  • AOS version: newest
  • OS: Windows
  • Browser: Chrome

Expected Behavior

Animation should trigger

Actual Behavior

No animations

Steps to Reproduce the Problem

Portfolio section has cards with images and there is "load more" button to display more cards. Code below

    <script>
      const loadMore = document.getElementById('btn');
      const hid = [...document.querySelectorAll('.foto-container.hidden')];

      hid.splice(0, 9).forEach(
        elem => elem.classList.remove('hidden')
      );

      loadMore.addEventListener('click', function(e) {
        e.preventDefault();
        
        hid.splice(0, 6).forEach(
          elem => elem.classList.remove('hidden')
        )
        
        if (hid.length == 0) {
          loadMore.classList.add('hidden');
        }
      });
    </script>

Detailed Description

Animations above and below "load more" feature works well, but when I click "load more" button and more cards are displayed, then below animations on the page are triggered as well, so when I scroll the page to buttom then elements are after animations already. Animations shouldn't trigger when clicked "load more" feature.

Possible Solution

@Bammede Bammede changed the title No animation below the "load more" feature Animation trigger too earlier when using other script like "load more" cards Sep 17, 2023
@Bammede Bammede changed the title Animation trigger too earlier when using other script like "load more" cards Animation trigger too early when using other script like "load more" cards Sep 17, 2023
@markmorris
Copy link

Each time you add something to DOM, you need to use AOS.refresh();

We do something similar with Filtering hiding and showing new DOM Elements.

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

2 participants