A bad but quick fix for this would be to map touch events to mouse on your odometers. Taken from https://stackoverflow.com/a/1781750/3946520
function touchHandler(event)
{
var touches = event.changedTouches,
first = touches[0],
type = "";
switch(event.type)
{
case "touchstart": type = "mousedown"; break;
case "touchmove": type = "mousemove"; break;
case "touchend": type = "mouseup"; break;
default: return;
}
var simulatedEvent = document.createEvent("MouseEvent");
simulatedEvent.initMouseEvent(type, true, true, window, 1,
first.screenX, first.screenY,
first.clientX, first.clientY, false,
false, false, false, 0/*left*/, null);
first.target.dispatchEvent(simulatedEvent);
event.preventDefault();
}
function mapTouchToMouse(elem)
{
elem.addEventListener("touchstart", touchHandler, true);
elem.addEventListener("touchmove", touchHandler, true);
elem.addEventListener("touchend", touchHandler, true);
elem.addEventListener("touchcancel", touchHandler, true);
}
mapTouchToMouse(document.getElementById("p1-odometer"));
mapTouchToMouse(document.getElementById("p2-odometer"));
Also to make it work on edge and IE, add the style properties touch-action: none; -ms-touch-action:none;
to your SVG elements:
<svg id="p2-odometer" width="100%" viewBox="-26 -26 57 52" background="#eee" style="touch-action:none; -ms-touch-action:none;">
<svg id="p1-odometer" width="100%" viewBox="-26 -26 57 52" background="#eee" style="touch-action:none; -ms-touch-action:none;">
Also you don't have to load touch-punch jquery-ui extension to the page for this method to work.
If you don't want this method and want to go by custom touch handling, then you need to use these events: 'touchstart', 'touchmove', 'touchend', 'touchcancel'
in place of 'mousedown', 'mousemove', 'mouseup', 'mouseleave'
. And make corresponding changes in the handler functions for these events. I hope this helps.