(e, layerdict)
| 876 | } |
| 877 | |
| 878 | function 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 | |
| 923 | function handlePointerMove(e, layerdict) { |
| 924 | if (!layerdict.pointerStates.hasOwnProperty(e.pointerId)) { |
no test coverage detected