javascript - Any idea how to make this script touch-friendly? -


a bit background info: simple game http://deslimmespeeltuin.nl/speeltuin.htm going part of educational project children. based on marco kuiper's nice polaroid viewer (http://demo.marcofolio.net/polaroid_photo_viewer). original script bit old , had update jquery libraries references work on latest ie, example. however, doesn't work on touch devices (android / ios), real pity. although looks right, cannot drag shapes.

i'm not programmer. marco himself help, busy. have clue? advice great.

if add html file should work:

<script> function touchhandler(event) {     var touch = event.changedtouches[0];      var simulatedevent = document.createevent("mouseevent");         simulatedevent.initmouseevent({         touchstart: "mousedown",         touchmove: "mousemove",         touchend: "mouseup"     }[event.type], true, true, window, 1,         touch.screenx, touch.screeny,         touch.clientx, touch.clienty, false,         false, false, false, 0, null);      touch.target.dispatchevent(simulatedevent);     event.preventdefault(); }  function init() {     document.addeventlistener("touchstart", touchhandler, true);     document.addeventlistener("touchmove", touchhandler, true);     document.addeventlistener("touchend", touchhandler, true);     document.addeventlistener("touchcancel", touchhandler, true); }  // call init function when document has finished loading. $(document).ready(function(){     init(); }); </script> 

this here: javascript drag , drop touch devices have tested emulating touch events in chrome after running code through console , works on example site.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -