joaopereirawd / animatedModal.js

animatedModal.js is a jQuery plugin to create a fullscreen modal with CSS3 transitions. You can use the transitions from animate.css or create your own transitions.
MIT License
962 stars 207 forks source link

Scroll events not triggered once modal window opened #35

Closed wazzzzza closed 8 years ago

wazzzzza commented 8 years ago

Hi,

I have a scroll event listener which works fine until a modal is opened. Once it is launched, the listener doesn't trigger any scroll event anymore. I tried removing the listener on beforeOpen and adding it again on beforeClose but it didn't fix the issue:

$("#modal01").animatedModal({color:"rgba(0, 0, 0, 0.8)", beforeOpen: function() { window.removeEventListener('scroll', checkScrollY, false);  }, afterClose: function() { window.addEventListener('scroll', checkScrollY, false);  } });

function checkScrollY(){
  console.log(window.scrollY);
}

Would you have any idea?

Cheers

wazzzzza commented 8 years ago

Solution found.

Applied the fix from @imoddesign:

afterClose: function() {
  $('body').removeAttr('style');
}

On close, overflow=auto causes problems

Thanks