MCPcopy Index your code
hub / github.com/reactive-python/reactpy / triggerIfInViewport

Function triggerIfInViewport

docs/source/_custom_js/src/index.js:80–94  ·  view source on GitHub ↗
(element, callback)

Source from the content-addressed store, hash-verified

78}
79
80function triggerIfInViewport(element, callback) {
81 const observer = new window.IntersectionObserver(
82 ([entry]) => {
83 if (entry.isIntersecting) {
84 callback();
85 }
86 },
87 {
88 root: null,
89 threshold: 0.1, // set offset 0.1 means trigger if at least 10% of element in viewport
90 },
91 );
92
93 observer.observe(element);
94}

Callers 1

mountWidgetExampleFunction · 0.85

Calls 1

callbackFunction · 0.85

Tested by

no test coverage detected