(el)
| 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(); |
nothing calls this directly
no test coverage detected