Home » Angularjs » Best practice for when element is visible on the screen?

Best practice for when element is visible on the screen?

Posted by: admin November 30, 2017 Leave a comment

Questions:

In angular, I want to trigger a function and/or set a css-class once an element is actually visible on the screen, as in once you scroll down for example. What’s the best practice for this?

Answers:

I was trying to do the same thing and after lot of research I found a directive that does exactly what I needed:

https://github.com/thenikso/angular-inview

It was also very easy to setup. In case you run into issues with this then let me know and I can help you out.

Questions:
Answers:

You may want to simply build a directive over a library like ifvisible.js.