Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Detect when a div is outside of the screen

I have a page where I can order a product. So there is a "buy" button.

I would like, when the user scrolls down, when the button disappear to create a fixed bar at botttom of screen with this same button "Buy".

I was wondering if I have to do it like this :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

screenHeight = window.innerHeight;

if (screenHeight > 400) { // do this }
else { // do this }

Or maybe there is a proper way to do this. Detecting when this button goes out of displayed screen ?

I am working with React.

Thank you

>Solution :

you can use this package react-intersection-observer

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading