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.

1

1 Answer 1

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
});
Sign up to request clarification or add additional context in comments.

1 Comment

Yes the page you suggested solved the problem, thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.