Skip to content

Instantly share code, notes, and snippets.

@sehv
Forked from nicholasklick/touch-tooltip-fix.js
Last active August 29, 2015 14:20
Show Gist options
  • Save sehv/928f356afd6b68eb28e2 to your computer and use it in GitHub Desktop.
Save sehv/928f356afd6b68eb28e2 to your computer and use it in GitHub Desktop.
//Fixes an issue with pinch zooming in previous versions of this fix:
//zooming worked, but the Reset Zoom button never appeared. Changing which tracker event is called takes care of this.
//Tested in 4.1.4 on Android
Highcharts.Chart.prototype.callbacks.push(function (chart) {
var hasTouch = document.documentElement.ontouchstart !== undefined,
mouseTracker = chart.pointer,
container = chart.container,
mouseMove;
mouseMove = function (e) {
if (hasTouch) {
if (e && e.touches && e.touches.length > 1) {
mouseTracker.onContainerTouchStart(e);
} else {
return;
}
} else {
mouseTracker.onContainerMouseMove(e);
}
};
click = function (e) {
if (hasTouch) {
mouseTracker.onContainerMouseMove(e);
}
mouseTracker.onContainerClick(e);
}
container.onmousemove = container.ontouchstart = container.ontouchmove = mouseMove;
container.onclick = click;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment