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

Function handleMouseWheel

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

Source from the content-addressed store, hash-verified

971}
972
973function handleMouseWheel(e, layerdict) {
974 e.preventDefault();
975 e.stopPropagation();
976 var t = layerdict.transform;
977 var wheeldelta = e.deltaY;
978 if (e.deltaMode == 1) {
979 // FF only, scroll by lines
980 wheeldelta *= 30;
981 } else if (e.deltaMode == 2) {
982 wheeldelta *= 300;
983 }
984 var m = Math.pow(1.1, -wheeldelta / 40);
985 // Limit amount of zoom per tick.
986 if (m > 2) {
987 m = 2;
988 } else if (m < 0.5) {
989 m = 0.5;
990 }
991 t.zoom *= m;
992 var zoomd = (1 - m) / t.zoom;
993 t.panx += devicePixelRatio * e.offsetX * zoomd;
994 t.pany += devicePixelRatio * e.offsetY * zoomd;
995 redrawCanvas(layerdict);
996}
997
998function addMouseHandlers(div, layerdict) {
999 div.addEventListener("pointerdown", function(e) {

Callers 1

addMouseHandlersFunction · 0.85

Calls 1

redrawCanvasFunction · 0.85

Tested by

no test coverage detected