Is it possible for js to know when an element is shown on the screen

Viewed 29

I made a slider, and i want it to stop when it reaches the last element on it. The slider moves by 50 vw every time the button is clicked. The problem is that the slider shows more or less of itself depending on the width of the window. So is there a way for js to know to stop when the last box of the slider is on the screen?

video of the slider: https://drive.google.com/file/d/1h-CKnegsa4vF7J0y0AiwoJFkUrnCTX7s/view?usp=sharing

1 Answers

Try out intersection observer Api. Read more in this link

Related