MCPcopy Create free account
hub / github.com/openscopeproject/InteractiveHtmlBom / handleMouseClick

Function handleMouseClick

InteractiveHtmlBom/web/render.js:828–858  ·  view source on GitHub ↗
(e, layerdict)

Source from the content-addressed store, hash-verified

826}
827
828function handleMouseClick(e, layerdict) {
829 if (!e.hasOwnProperty("offsetX")) {
830 // The polyfill doesn't set this properly
831 e.offsetX = e.pageX - e.currentTarget.offsetLeft;
832 e.offsetY = e.pageY - e.currentTarget.offsetTop;
833 }
834
835 var x = e.offsetX;
836 var y = e.offsetY;
837 var t = layerdict.transform;
838 var flip = layerdict.layer === "B";
839 if (flip) {
840 x = (devicePixelRatio * x / t.zoom - t.panx + t.x) / -t.s;
841 } else {
842 x = (devicePixelRatio * x / t.zoom - t.panx - t.x) / t.s;
843 }
844 y = (devicePixelRatio * y / t.zoom - t.y - t.pany) / t.s;
845 var v = rotateVector([x, y], -settings.boardRotation + (flip && settings.offsetBackRotation ? - 180 : 0));
846 if ("nets" in pcbdata) {
847 var net = netHitScan(layerdict.layer, ...v);
848 if (net !== highlightedNet) {
849 netClicked(net);
850 }
851 }
852 if (highlightedNet === null) {
853 var footprints = bboxHitScan(layerdict.layer, ...v);
854 if (footprints.length > 0) {
855 footprintsClicked(footprints);
856 }
857 }
858}
859
860function handlePointerLeave(e, layerdict) {
861 e.preventDefault();

Callers 1

handlePointerUpFunction · 0.85

Calls 5

rotateVectorFunction · 0.85
netHitScanFunction · 0.85
netClickedFunction · 0.85
bboxHitScanFunction · 0.85
footprintsClickedFunction · 0.85

Tested by

no test coverage detected