Skip to content

Commit

Permalink
Added new option, tooltip.followTouchMove. When this is true, the too…
Browse files Browse the repository at this point in the history
…ltip can be moved by dragging a single finger across the chart, like in Highcharts 2. When it is false, dragging a single finger is ignored by the chart, and causes the whole page to scroll. This applies only when zooming is not enabled. Closes #1644. Closes #1662.
  • Loading branch information
TorsteinHonsi committed Apr 3, 2013
1 parent b630a38 commit 49e18e0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 15 deletions.
16 changes: 11 additions & 5 deletions js/highcharts.src.js
Original file line number Diff line number Diff line change
Expand Up @@ -9176,21 +9176,24 @@ Pointer.prototype = {
var self = this,
chart = self.chart,
pinchDown = self.pinchDown,
followTouchMove = chart.tooltip.options.followTouchMove, // docs
touches = e.touches,
touchesLength = touches.length,
lastValidTouch = self.lastValidTouch,
zoomHor = self.zoomHor || self.pinchHor,
zoomVert = self.zoomVert || self.pinchVert,
hasZoom = zoomHor || zoomVert,
selectionMarker = self.selectionMarker,
transform = {},
clip = {};

// On touch devices, only proceed to trigger click if a handler is defined
if (e.type === 'touchstart') {
if (e.type === 'touchstart' && followTouchMove) {
if (self.inClass(e.target, PREFIX + 'tracker')) {
if (!chart.runTrackerClick) {
if (!chart.runTrackerClick || touchesLength > 1) {
e.preventDefault();
}
} else if (!chart.runChartClick) {
} else if (!chart.runChartClick || touchesLength > 1) {
e.preventDefault();
}
}
Expand Down Expand Up @@ -9244,12 +9247,15 @@ Pointer.prototype = {
self.pinchTranslateDirection(false, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
}

self.hasPinched = zoomHor || zoomVert;
self.hasPinched = hasZoom;

// Scale and translate the groups to provide visual feedback during pinching
self.scaleGroups(transform, clip);


// Optionally move the tooltip on touchmove
if (!hasZoom && followTouchMove && touchesLength === 1) {
this.runPointActions(self.normalize(e));
}
}
},

Expand Down
16 changes: 11 additions & 5 deletions js/highstock.src.js
Original file line number Diff line number Diff line change
Expand Up @@ -9176,21 +9176,24 @@ Pointer.prototype = {
var self = this,
chart = self.chart,
pinchDown = self.pinchDown,
followTouchMove = chart.tooltip.options.followTouchMove, // docs
touches = e.touches,
touchesLength = touches.length,
lastValidTouch = self.lastValidTouch,
zoomHor = self.zoomHor || self.pinchHor,
zoomVert = self.zoomVert || self.pinchVert,
hasZoom = zoomHor || zoomVert,
selectionMarker = self.selectionMarker,
transform = {},
clip = {};

// On touch devices, only proceed to trigger click if a handler is defined
if (e.type === 'touchstart') {
if (e.type === 'touchstart' && followTouchMove) {
if (self.inClass(e.target, PREFIX + 'tracker')) {
if (!chart.runTrackerClick) {
if (!chart.runTrackerClick || touchesLength > 1) {
e.preventDefault();
}
} else if (!chart.runChartClick) {
} else if (!chart.runChartClick || touchesLength > 1) {
e.preventDefault();
}
}
Expand Down Expand Up @@ -9244,12 +9247,15 @@ Pointer.prototype = {
self.pinchTranslateDirection(false, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
}

self.hasPinched = zoomHor || zoomVert;
self.hasPinched = hasZoom;

// Scale and translate the groups to provide visual feedback during pinching
self.scaleGroups(transform, clip);


// Optionally move the tooltip on touchmove
if (!hasZoom && followTouchMove && touchesLength === 1) {
this.runPointActions(self.normalize(e));
}
}
},

Expand Down
16 changes: 11 additions & 5 deletions js/parts/Pointer.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,21 +341,24 @@ Pointer.prototype = {
var self = this,
chart = self.chart,
pinchDown = self.pinchDown,
followTouchMove = chart.tooltip.options.followTouchMove, // docs
touches = e.touches,
touchesLength = touches.length,
lastValidTouch = self.lastValidTouch,
zoomHor = self.zoomHor || self.pinchHor,
zoomVert = self.zoomVert || self.pinchVert,
hasZoom = zoomHor || zoomVert,
selectionMarker = self.selectionMarker,
transform = {},
clip = {};

// On touch devices, only proceed to trigger click if a handler is defined
if (e.type === 'touchstart') {
if (e.type === 'touchstart' && followTouchMove) {
if (self.inClass(e.target, PREFIX + 'tracker')) {
if (!chart.runTrackerClick) {
if (!chart.runTrackerClick || touchesLength > 1) {
e.preventDefault();
}
} else if (!chart.runChartClick) {
} else if (!chart.runChartClick || touchesLength > 1) {
e.preventDefault();
}
}
Expand Down Expand Up @@ -409,12 +412,15 @@ Pointer.prototype = {
self.pinchTranslateDirection(false, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
}

self.hasPinched = zoomHor || zoomVert;
self.hasPinched = hasZoom;

// Scale and translate the groups to provide visual feedback during pinching
self.scaleGroups(transform, clip);


// Optionally move the tooltip on touchmove
if (!hasZoom && followTouchMove && touchesLength === 1) {
this.runPointActions(self.normalize(e));
}
}
},

Expand Down

0 comments on commit 49e18e0

Please sign in to comment.