0

I want to float a layer as soon as I am scrolling to a certain point on a page. But my page is not static in height, but (very) dynamic. So this known solution will not work for me:

if($(window).scrollTop() > 1000) { 
   // do this
}

That's the reason I am wondering if there is a posibility to fire an event at the very moment a certain object (e.g. a div) has appeared on my screen?

Other solutions are also welcome of course.

Vincent
  • 81
  • 8
  • 2
    Possible duplicate of http://stackoverflow.com/questions/487073/check-if-element-is-visible-after-scrolling – Toby Jul 24 '16 at 18:34

1 Answers1

1

You can check this answer here Check if element is visible after scrolling

And after you can trigger the event like this

$(document).trigger('elementVisible');

And here you can add your code

$(document).on('elementVisible', function (event, data) {
  //code goes here
});
Community
  • 1
  • 1
driantn
  • 26
  • 2