question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is rootMargin working?

See original GitHub issue

In the recipe for lazy loading images here https://github.com/thebuilder/react-intersection-observer/blob/master/docs/Recipes.md#lazy-image-load I haven’t been able to observe any effect related to rootMargin

This is, images were loading always when barely seen, not before or after

How is this supposed to work?

*In the link example in https://codesandbox.io/embed/lazy-image-load-mjsgc one has to "false"fy the native image loading browser capabilities to test this - in both files (and remove the loading prop)

 const supportsLazyLoading = false;

And the margin has also to be corrected to rootMargin (I assume)

EDIT: I can see that it is working in other examples where I am triggering animations, but with the one of images It seems to be ignored (?)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
Zlokacommented, Dec 2, 2020

@thebuilder I went over how I assigned root and noticed a mistake. Lesson learned, don’t code (or raise issues) while tired. Thanks for the quick reply and handy useInView hook, works as expected now 😌

1reaction
thebuildercommented, Nov 30, 2020

@juanpprieto I seem to be running into the same issue you described. Do you happen to have a code snippet to share? I can’t seem to wrap my head around it 🙁

  • Are you setting root?
  • Is it rendered inside an <iframe>?

Can you share the an example on Codesandbox?

Read more comments on GitHub >

github_iconTop 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 >
Intersection Observer rootMargin not working as expected on ...
Result: Image only loads when intersecting at viewport , which rootMargin seems to not be working on horizontal level. Here is an example:...
Read more >
IntersectionObserver.rootMargin - Web APIs
See The root element and root margin in Intersection Observer API for a more in-depth look at the root margin and how it...
Read more >
An Explanation of How the Intersection Observer Watches
The rootMargin is a string of values describing what can be called the margin of the root element, which affects the resulting bounding...
Read more >
JavaScript Intersection Observer Ultimate Guide
Now let's break apart how this all works. ... The next useful option you can pass to an Intersection Observer is rootMargin ....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found