Consider adding `rootMargin` to the Intersection Observer
See original GitHub issueFeedback from @surma:
I feel like by default you should add a rootMargin to the IO to trigger the load before something comes into the viewport.
So, rootMargin
defaults to “0px 0px 0px 0px”, meaning the intersection will be computed between the root element’s unmodified bounds rectangle and the target’s bounds. This change would be made to https://github.com/GoogleChromeLabs/quicklink/blob/master/src/index.mjs#L21
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:13 (4 by maintainers)
Top Results From Across the Web
IntersectionObserver.rootMargin - Web APIs | MDN
The IntersectionObserver interface's read-only rootMargin property is a string with syntax similar to that of the CSS margin property.
Read more >Use IntersectionObserver with rootMargin to change when ...
I'm completely flummoxed by the rootMargin property of intersection observer. My goal is to add a class to an element when half it's...
Read more >JavaScript Intersection Observer Ultimate Guide
The rootMargin will be added to the container viewport so in essence we can shrink/grow our view port with this value. const observer...
Read more >master the `rootMargin` option in intersection observer.
A possible solution is to add a margin-left for the first item and a margin-right for the last item of marginWidth , then...
Read more >IntersectionObserver.rootMargin - Web APIs
The IntersectionObserver interface's read-only rootMargin property is a string with syntax similar to that of the CSS margin property.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@lukeed @addyosmani I’d be happy to do whatever is needed. I’ll make a PR once I’m done.
Edit: I’m getting a microbundle related jsx error that I need to investigate. Once I fix that, I’ll make a PR.
@lukeed Mostly me being overscrupulous 😇
I haven’t measured IO initialization costs so don’t have a good mental model of whether this shift practically changes anything. Let’s move ahead 👍I’ll flag if any concerns can be backed up with data.