Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docsSource/sections/03-best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,19 @@ Most of the Animate.css animations will move elements across the screen and migh
### Intervals between repeats

Unfortunately, this isn't possible with pure CSS right now. You have to use Javascript to achieve this result.

### Combining page-load and hover animations

Applying a page-load animation and a hover animation to the same element can cause an unexpected restart of the entrance animation after the hover animation finishes. This happens because browsers re-evaluate the `animation` property whenever it changes (e.g., when a class is added or removed on hover), which resets the animation cycle.

The recommended fix is to remove the page-load animation classes with Javascript once the animation is complete, so there is nothing to restart:

```javascript
const element = document.querySelector('.my-element');

element.addEventListener('animationend', () => {
element.classList.remove('animate__animated', 'animate__fadeIn');
}, {once: true});
```

After removing those classes the hover animation works independently and the entrance animation will not be restarted.