by adom
0402 SMD Red LED · 2.1 V drop · 25 mA max
← Commit history
Contain the wheel inside the 3D viewer so zooming the model no longer scrolls the wiki page underneath
2 files changed
+35
README.html+23@@ -1746,6 +1746,29 @@ } catch (e) { statusEl.textContent = 'init error: ' + e.message; window._err = (e.stack || e.message); console.error(e); } })(); </script>++<style>html,body{overscroll-behavior:none}</style>+<script>+/* Keep the wheel inside the viewer. Capture phase + passive:false so this runs BEFORE+ Babylon's own handler and is actually allowed to cancel. Registered in its own script+ tag: if the viewer's init throws, this still binds. */+(function () {+ addEventListener('wheel', function (e) {+ // Let a genuinely scrollable panel scroll itself; only cancel once it has nowhere left+ // to go (which is what would otherwise chain out to the page).+ for (var n = e.target; n && n !== document.documentElement; n = n.parentElement) {+ var oy = getComputedStyle(n).overflowY;+ if ((oy === 'auto' || oy === 'scroll') && n.scrollHeight > n.clientHeight) {+ var atTop = n.scrollTop <= 0;+ var atEnd = n.scrollTop + n.clientHeight >= n.scrollHeight - 1;+ if (!(e.deltaY < 0 && atTop) && !(e.deltaY > 0 && atEnd)) return;+ break;+ }+ }+ e.preventDefault();+ }, { passive: false, capture: true });+})();+</script> " title="IN-S42ATR 3D assembly viewer" sandbox="allow-scripts allow-popups" allow="fullscreen"></iframe> </div>
README.md+12@@ -47,6 +47,18 @@ Interactive symbol and footprint viewers, side by side, generated with into `README.html` as `srcdoc` — a nested `<iframe src=…>` cannot work, because the wiki serves the README sandboxed without `allow-same-origin`. +### Scroll containment++The 3D viewer is inlined with a small patch appended (`VIEWER_SCROLL_PATCH` in+`gen/build_readme.py`, deliberately kept out of `gen/timeline-viewer.html` so that file stays+the pristine extracted copy). Without it, scrolling to zoom the model also scrolled the wiki+page: the viewer document registers no wheel listener of its own — Babylon attaches one for+camera dolly and never calls `preventDefault` — so the compositor scrolled the nearest+scrollable ancestor without even dispatching a wheel event into the viewer frame. The+`adom-symbol` and `adom-footprint` embeds already `preventDefault` in their own wheel+handlers, which is why only the 3D viewer leaked. Regression test:+`preview/check-scroll-capture.mjs` (build with `--no-viewer-patch` to see it fail).+ ## Datasheet **IN-S42AT series — Top View SMD LED 0402 PCB Type**, V1.1, revised 25 April 2017, 14 pages,