MCPcopy
hub / github.com/d3/d3 / mounted

Function mounted

docs/components/PlotRender.js:150–171  ·  view source on GitHub ↗
(el)

Source from the content-addressed store, hash-verified

148 };
149 if (this.defer) {
150 const mounted = (el) => {
151 disconnect(); // remove old listeners
152 function observed() {
153 unmounted(el); // remove old plot (and listeners)
154 el.append(Plot[method](options));
155 }
156 const rect = el.getBoundingClientRect();
157 if (rect.bottom > 0 && rect.top < window.innerHeight) {
158 observed();
159 } else {
160 this._observer = new IntersectionObserver(
161 ([entry]) => {
162 if (entry.isIntersecting) observed();
163 },
164 {rootMargin: "100px"}
165 );
166 this._observer.observe(el);
167 if (typeof requestIdleCallback === "function") {
168 this._idling = requestIdleCallback(observed);
169 }
170 }
171 };
172 const unmounted = (el) => {
173 while (el.lastChild) el.lastChild.remove();
174 disconnect();

Callers

nothing calls this directly

Calls 2

observedFunction · 0.85
disconnectFunction · 0.70

Tested by

no test coverage detected