javascript - How can I allow two-finger scrolling over an HTML canvas element while allowing one-finger drawing? -


i attempting make canvas drawing app fixed size canvas - ability scroll around canvas draw on different points may not visible based on user's screen size.

it scrolls on desktop, trying implement 2 finger scrolling on mobile.

http://jsbin.com/qugabuh/edit

in touch-drawing functions, tried following:

const starttouch = function(e) {   if (e.targettouches.length < 2) {     ctx.beginpath();     x = e.changedtouches[0].pagex + content.scrollleft;     y = e.changedtouches[0].pagey - 34 + content.scrolltop;     ctx.moveto(x, y);   } };  const movetouch = function(e) {   if (e.targettouches.length < 2) {     e.preventdefault();     x = e.changedtouches[0].pagex + content.scrollleft;     y = e.changedtouches[0].pagey - 34 + content.scrolltop;     ctx.lineto(x, y);     ctx.stroke();   } }; 

this seems work okay on android tablet (although lines draw if don't lift both fingers off @ exact same time), not @ on iphone.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -