Skip to content

The ambiguity of intersectionRatio. #488

Open
@joekingTheThird3

Description

@joekingTheThird3

This is usually zero or larger. But the zero value is still valid and means at least 1 pixel is 'intersecting'. I've seen repeated code test just the intersectionRatio, 'intersectionRatio > 0'. This can cause some issues when scrolling because if it is zero then the test would miss the movement of the target element inside the root. I usually change the test to >= 0. I also test the isIntersecting property. I think people are using this shortcut for 'has this element moved inside the area I want to observe'. IntersectionRatio can never be less than zero? Maybe it should?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions