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

Function handlePointerUp

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

Source from the content-addressed store, hash-verified

876}
877
878function handlePointerUp(e, layerdict) {
879 if (!e.hasOwnProperty("offsetX")) {
880 // The polyfill doesn't set this properly
881 e.offsetX = e.pageX - e.currentTarget.offsetLeft;
882 e.offsetY = e.pageY - e.currentTarget.offsetTop;
883 }
884
885 e.preventDefault();
886 e.stopPropagation();
887
888 if (e.button == 2) {
889 // Reset pan and zoom on right click.
890 resetTransform(layerdict);
891 layerdict.anotherPointerTapped = false;
892 return;
893 }
894
895 // We haven't necessarily had a pointermove event since the interaction started, so make sure we update this now
896 var ptr = layerdict.pointerStates[e.pointerId];
897 ptr.distanceTravelled += Math.abs(e.offsetX - ptr.lastX) + Math.abs(e.offsetY - ptr.lastY);
898
899 if (e.button == 0 && ptr.distanceTravelled < 10 && Date.now() - ptr.downTime <= 500) {
900 if (Object.keys(layerdict.pointerStates).length == 1) {
901 if (layerdict.anotherPointerTapped) {
902 // This is the second pointer coming off of a two-finger tap
903 resetTransform(layerdict);
904 } else {
905 // This is just a regular tap
906 handleMouseClick(e, layerdict);
907 }
908 layerdict.anotherPointerTapped = false;
909 } else {
910 // This is the first finger coming off of what could become a two-finger tap
911 layerdict.anotherPointerTapped = true;
912 }
913 } else {
914 if (!settings.redrawOnDrag) {
915 redrawCanvas(layerdict);
916 }
917 layerdict.anotherPointerTapped = false;
918 }
919
920 delete layerdict.pointerStates[e.pointerId];
921}
922
923function handlePointerMove(e, layerdict) {
924 if (!layerdict.pointerStates.hasOwnProperty(e.pointerId)) {

Callers 1

addMouseHandlersFunction · 0.85

Calls 3

resetTransformFunction · 0.85
handleMouseClickFunction · 0.85
redrawCanvasFunction · 0.85

Tested by

no test coverage detected