Permalink
Browse files

Possible fix for issue with stuck tooltips, issue #149.

  • Loading branch information...
1 parent d0e00f6 commit 54537ff43c4b9211d8b148979fa22081528dad0e highslide-software committed Aug 5, 2011
Showing with 45 additions and 5 deletions.
  1. +24 −4 js/highcharts.src.js
  2. +21 −1 js/parts/Chart.js
View
@@ -2,7 +2,7 @@
// @compilation_level SIMPLE_OPTIMIZATIONS
/**
- * @license Highcharts JS v2.1.6 (2011-07-08)
+ * @license @product.name@ JS v@product.version@ (@product.date@)
*
* (c) 2009-2011 Torstein Hønsi
*
@@ -3958,6 +3958,7 @@ function Chart(options, callback) {
eventType,
isInsidePlot, // function
tooltip,
+ tooltipTimer,
mouseIsDown,
loadingDiv,
loadingSpan,
@@ -6239,6 +6240,8 @@ function Chart(options, callback) {
tooltip.hide();
}
+ clearTimeout(tooltipTimer);
+
hoverX = null;
}
@@ -6361,7 +6364,7 @@ function Chart(options, callback) {
if (!lastWasOutsidePlot) {
// reset the tracker
- resetTracker();
+ resetTracker();
}
// drop the selection if any and reset mouseIsDown and hasDragged
@@ -6447,6 +6450,23 @@ function Chart(options, callback) {
*/
addEvent(container, 'mouseleave', resetTracker);
+ // issue #149 workaround
+ // to do: check whether the container position is somehow cached, so we don't
+ // have to run the expensive getPosition. In that case, we can remove the
+ // tooltip instantly on mousemoves outside the plot area.
+ function setTooltipTimer(e) {
+ clearTimeout(tooltipTimer);
+ tooltipTimer = setTimeout (function() {
+ chartPosition = getPosition(container);
+ if (!isInsidePlot(e.pageX - chartPosition.left - plotLeft, e.pageY - chartPosition.top - plotTop)) {
+ resetTracker();
+ } else {
+ setTooltipTimer(e);
+ }
+ }, 3000);
+ }
+ addEvent(document, 'mousemove', setTooltipTimer);
+
container.ontouchstart = function (e) {
// For touch devices, use touchmove to zoom
@@ -11069,7 +11089,7 @@ win.Highcharts = {
merge: merge,
pick: pick,
extendClass: extendClass,
- product: 'Highcharts',
- version: '2.1.6'
+ product: '@product.name@',
+ version: '@product.version@'
};
}());
View
@@ -56,6 +56,7 @@ function Chart(options, callback) {
eventType,
isInsidePlot, // function
tooltip,
+ tooltipTimer,
mouseIsDown,
loadingDiv,
loadingSpan,
@@ -2337,6 +2338,8 @@ function Chart(options, callback) {
tooltip.hide();
}
+ clearTimeout(tooltipTimer);
+
hoverX = null;
}
@@ -2459,7 +2462,7 @@ function Chart(options, callback) {
if (!lastWasOutsidePlot) {
// reset the tracker
- resetTracker();
+ resetTracker();
}
// drop the selection if any and reset mouseIsDown and hasDragged
@@ -2545,6 +2548,23 @@ function Chart(options, callback) {
*/
addEvent(container, 'mouseleave', resetTracker);
+ // issue #149 workaround
+ // to do: check whether the container position is somehow cached, so we don't
+ // have to run the expensive getPosition. In that case, we can remove the
+ // tooltip instantly on mousemoves outside the plot area.
+ function setTooltipTimer(e) {
+ clearTimeout(tooltipTimer);
+ tooltipTimer = setTimeout (function() {
+ chartPosition = getPosition(container);
+ if (!isInsidePlot(e.pageX - chartPosition.left - plotLeft, e.pageY - chartPosition.top - plotTop)) {
+ resetTracker();
+ } else {
+ setTooltipTimer(e);
+ }
+ }, 3000);
+ }
+ addEvent(document, 'mousemove', setTooltipTimer);
+
container.ontouchstart = function (e) {
// For touch devices, use touchmove to zoom

0 comments on commit 54537ff

Please sign in to comment.