[useIntersectionObserver] Introduce new API
See original GitHub issueNote: This proposal is in its very early stage.
The Intersection Observer API provides a way to asynchronously observe changes in the intersection of a target element with an ancestor element or with a top-level document’s viewport.
- This is not a v0.x issue.
- I have searched the issues of this repository and believe that this is not a duplicate.
Expected Behavior 🤔
Implementation should somewhat look like useScrollTrigger
Current Behavior 😯
User implemented
Examples 🌈
Context 🔦
- Mount component when it intersects with the DOM.
Benchmark
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Intersection Observer API - MDN Web Docs
The Intersection Observer API provides a way to asynchronously observe changes in the intersection of a target element with an ancestor ...
Read more >Introducing the Intersection Observer API | by John Au-Yeung
In this article, we'll look at how to use the Intersection Observer API to watch for visibility changes for a child element.
Read more >Intersection Observer - W3C
The Intersection Observer API enables developers to understand the visibility and position of target DOM elements relative to an intersection ...
Read more >What is Intersection Observer API and how is it useful?
Intersection Observer API is a browser API that can be used to observe and listen to the changes intersecting with the viewport.
Read more >Introduction to the Intersection Observer JavaScript API
Introduction to the Intersection Observer JavaScript API · You can find the code here: · Use the following link to get 2 FREE...
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
IMHO if you decide on using a generic library (e.g.
react-intersection-observer
)material-ui
itself should focus on providing a component-based API e.g. theReveal
component I propose in #23960 and not a hook-based API likeuseScrollTrigger
, because it would obfuscate the usage of the library somehow.To further expand on my reasoning.we can compare the usage rate between the generic API https://github.com/thebuilder/react-intersection-observer and the specialized one: https://github.com/jasonslyvia/react-lazyload, https://github.com/bvaughn/react-virtualized. There is a x10 difference. I believe working on this would be a distraction for us.
In the future, I think that it would be great to explore the potential of an image component for Material-UI. Maybe something that comes with display transition, lazyload, error handling. Not a priority either, but I’m wondering about the potential 🤔.