IntersectionObserver not working in Safari or iOS

后端 未结 2 589
孤独总比滥情好
孤独总比滥情好 2020-12-21 11:57

I have a piece of code that adds a different css class to elements depending on whether they\'re scrolled into or out of the viewport from top or bottom.

It uses the

相关标签:
2条回答
  • 2020-12-21 12:35

    Although I can't put my finger on the exact cause of the bug, I do have a solution:

    Try using document.body as the root and define sizes and scroll behavior to both html and body.

    I think this relates to document being more than a simple html node (I also tried using document.documentElement without success) and how Safari initializes the box model for it.

    Anyway, here's the updated working fiddle https://jsfiddle.net/gion_13/okrcgejt/8/ and screencasts of the tests on iOS and Mac Safari:

    0 讨论(0)
  • 2020-12-21 12:35

    I have had the same issue recently and to solve this I just had to

    set the root: null

    0 讨论(0)
提交回复
热议问题