A
A
account-62017-04-12 23:12:19
JavaScript
account-6, 2017-04-12 23:12:19

How to make an event when scrolling to a certain element?

How to make an EventListener when scrolling until a certain element appears on the page? I only mastered the scroll in pixels, but this is not accurate, since the screen sizes can change. Third-party libraries are not needed, how to do it in JS?
Let 's say I have
this.scrolled = window.scrollY > 100;
codepen.io/kodekrendel/pen/vmYeew now.
How can I make this event fire when I scroll to h2, for example?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Kulakov, 2017-04-13
@account-6

Alternatively: codepen.io/kerf/pen/NjWXqE

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question