Permalink
Browse files

Additional fix to #149

  • Loading branch information...
highslide-software
highslide-software committed Aug 8, 2011
1 parent 416fef5 commit 682fe4312798ccb5694277f799a75ff9acb829f2
Showing with 35 additions and 43 deletions.
  1. +19 −23 js/highcharts.src.js
  2. +16 −20 js/parts/Chart.js
View
@@ -2,7 +2,7 @@
// @compilation_level SIMPLE_OPTIMIZATIONS
/**
- * @license @product.name@ JS v@product.version@ (@product.date@)
+ * @license Highcharts JS v2.1.6 (2011-07-08)
*
* (c) 2009-2011 Torstein Hønsi
*
@@ -4013,7 +4013,6 @@ function Chart(options, callback) {
eventType,
isInsidePlot, // function
tooltip,
- tooltipTimer,
mouseIsDown,
loadingDiv,
loadingSpan,
@@ -6280,8 +6279,6 @@ function Chart(options, callback) {
tooltip.hide();
}
- clearTimeout(tooltipTimer);
-
hoverX = null;
}
@@ -6388,6 +6385,11 @@ function Chart(options, callback) {
chartY = e.chartY,
isOutsidePlot = !isInsidePlot(chartX - plotLeft, chartY - plotTop);
+ // cache chart position for issue #149 fix
+ if (!chartPosition) {
+ chartPosition = getPosition(container);
+ }
+
// on touch devices, only trigger click if a handler is defined
if (hasTouch && e.type === 'touchstart') {
if (attr(e.target, 'isTracker')) {
@@ -6402,10 +6404,10 @@ function Chart(options, callback) {
// cancel on mouse outside
if (isOutsidePlot) {
- if (!lastWasOutsidePlot) {
+ /*if (!lastWasOutsidePlot) {
// reset the tracker
resetTracker();
- }
+ }*/
// drop the selection if any and reset mouseIsDown and hasDragged
//drop();
@@ -6491,21 +6493,15 @@ 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);
+ // The mouseleave event above does not always fire. Whenever the mouse is moving
+ // outside the plotarea, hide the tooltip
+ addEvent(doc, 'mousemove', function (e) {
+ if (chartPosition &&
+ !isInsidePlot(e.pageX - chartPosition.left - plotLeft,
+ e.pageY - chartPosition.top - plotTop)) {
+ resetTracker();
+ }
+ });
container.ontouchstart = function (e) {
@@ -11129,7 +11125,7 @@ win.Highcharts = {
merge: merge,
pick: pick,
extendClass: extendClass,
- product: '@product.name@',
- version: '@product.version@'
+ product: 'Highcharts',
+ version: '2.1.6'
};
}());
View
@@ -56,7 +56,6 @@ function Chart(options, callback) {
eventType,
isInsidePlot, // function
tooltip,
- tooltipTimer,
mouseIsDown,
loadingDiv,
loadingSpan,
@@ -2323,8 +2322,6 @@ function Chart(options, callback) {
tooltip.hide();
}
- clearTimeout(tooltipTimer);
-
hoverX = null;
}
@@ -2431,6 +2428,11 @@ function Chart(options, callback) {
chartY = e.chartY,
isOutsidePlot = !isInsidePlot(chartX - plotLeft, chartY - plotTop);
+ // cache chart position for issue #149 fix
+ if (!chartPosition) {
+ chartPosition = getPosition(container);
+ }
+
// on touch devices, only trigger click if a handler is defined
if (hasTouch && e.type === 'touchstart') {
if (attr(e.target, 'isTracker')) {
@@ -2445,10 +2447,10 @@ function Chart(options, callback) {
// cancel on mouse outside
if (isOutsidePlot) {
- if (!lastWasOutsidePlot) {
+ /*if (!lastWasOutsidePlot) {
// reset the tracker
resetTracker();
- }
+ }*/
// drop the selection if any and reset mouseIsDown and hasDragged
//drop();
@@ -2534,21 +2536,15 @@ 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);
+ // The mouseleave event above does not always fire. Whenever the mouse is moving
+ // outside the plotarea, hide the tooltip
+ addEvent(doc, 'mousemove', function (e) {
+ if (chartPosition &&
+ !isInsidePlot(e.pageX - chartPosition.left - plotLeft,
+ e.pageY - chartPosition.top - plotTop)) {
+ resetTracker();
+ }
+ });
container.ontouchstart = function (e) {

0 comments on commit 682fe43

Please sign in to comment.