michalsnik / aos

Animate on scroll library
MIT License
26.84k stars 2.6k forks source link

Bug: JS Event Listener doesn't work. #463

Open lisongting95 opened 5 years ago

lisongting95 commented 5 years ago

This is: Bug

Specifications

Expected Behavior

document listener trigger and print something.

Actual Behavior

nothing happened, listener didn't work.

Steps to Reproduce the Problem

  1. add data-aos attribute to html element, data-aos-id='test' and so on. 2.add document event listener : document.addEventListener('aos:in', ({ detail }) => { console.log('animated in', detail); }); document.addEventListener('aos:in:test', ({ detail }) => { console.log('animated in', detail); });
  2. animation works but listeners do not work

Detailed Description

i added a click listener at the same place and it works.. document.addEventListener('click', () => { console.log('click'); });

Possible Solution

alexandre-stimpfling commented 5 years ago

Hi ! I confirm, impossible for me to make listeners work with v2.3.4.

lisongting95 commented 5 years ago

Well, I was trying to implement a series of animations by using these events listener. and "aos:in" listener works after the latest update. "aos:out" still doesn't works. I used xx.addEventListener('transitionend', () => {} , this transitionend listener instead

RenanEvangelista commented 5 years ago

I found the error, to be able to work you have to add the script at the end of the body equal to the domination like this:

Add script right before closing </ body> tag, and initialize AOS:

Githubissues.
  • Githubissues is a development platform for aggregating issues.