Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

References to effects in prototype adapter are kept until they are fi…

…nished or canceled. Closes #291
  • Loading branch information...
commit fc5a59e2fca0d19b8cad3cd95e8af0bc28e86ede 1 parent 682fe43
@eolsson eolsson authored
Showing with 20 additions and 4 deletions.
  1. +20 −4 js/adapters/prototype-adapter.src.js
View
24 js/adapters/prototype-adapter.src.js
@@ -40,7 +40,7 @@ return {
opts;
this.element = element;
-
+ this.key = attr;
from = element.attr(attr);
// special treatment for paths
@@ -67,7 +67,14 @@ return {
},
setup: function () {
HighchartsAdapter._extend(this.element);
- this.element._highchart_animation = this;
+ // If this is the first animation on this object, create the _highcharts_animation helper that
+ // contain pointers to the animation objects.
+ if (!this.element._highchart_animation) {
+ this.element._highchart_animation = {};
+ }
+
+ // Store a reference to this animation instance.
+ this.element._highchart_animation[this.key] = this;
},
update: function (position) {
var paths = this.paths;
@@ -79,7 +86,9 @@ return {
this.element.attr(this.options.attribute, position);
},
finish: function () {
- this.element._highchart_animation = null;
+ // Delete the property that holds this animation now that it is finished.
+ // Both canceled animations and complete ones gets a 'finish' call.
+ delete this.element._highchart_animation[this.key];
}
});
}
@@ -121,6 +130,8 @@ return {
// animate wrappers and DOM elements
if (hasEffect) {
for (key in params) {
+ // The fx variable is seemingly thrown away here, but the Effect.setup will add itself to the _highcharts_animation object
+ // on the element itself so its not really lost.
fx = new Effect.HighchartsTransition($(el), key, params[key], options);
}
} else {
@@ -136,8 +147,13 @@ return {
// this only occurs in higcharts 2.0+
stop: function (el) {
+ var key;
if (el._highcharts_extended && el._highchart_animation) {
- el._highchart_animation.cancel();
+ for (key in el._highchart_animation) {
+ // Cancel the animation
+ // The 'finish' function in the Effect object will remove the reference
+ el._highchart_animation[key].cancel();
+ }
}
},
Please sign in to comment.
Something went wrong with that request. Please try again.