projects
/
dygraphs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e0b3afa
)
Resize event causes several event handlers to be be added. Make the events private...
author
Robert Konigsberg
<konigsberg@google.com>
Fri, 25 Jan 2013 19:57:27 +0000
(14:57 -0500)
committer
Robert Konigsberg
<konigsberg@google.com>
Fri, 25 Jan 2013 19:57:27 +0000
(14:57 -0500)
dygraph.js
patch
|
blob
|
blame
|
history
diff --git
a/dygraph.js
b/dygraph.js
index
3803d9a
..
1a523b1
100644
(file)
--- a/
dygraph.js
+++ b/
dygraph.js
@@
-956,17
+956,19
@@
Dygraph.prototype.createInterface_ = function() {
var dygraph = this;
var dygraph = this;
- this.mouseMoveHandler = function(e) {
- dygraph.mouseMove_(e);
- };
- this.addEvent(this.mouseEventElement_, 'mousemove', this.mouseMoveHandler);
+ // Don't recreate and register the handlers on subsequent calls.
+ // This happens when the graph is resized.
+ if (!this.mouseMoveHandler_) {
+ this.mouseMoveHandler_ = function(e) {
+ dygraph.mouseMove_(e);
+ };
+ this.addEvent(this.mouseEventElement_, 'mousemove', this.mouseMoveHandler_);
-
this.mouseOutHandler
= function(e) {
- dygraph.mouseOut_(e);
- };
-
this.addEvent(this.mouseEventElement_, 'mouseout', this.mouseOutHandler
);
+
this.mouseOutHandler_
= function(e) {
+
dygraph.mouseOut_(e);
+
};
+
this.addEvent(this.mouseEventElement_, 'mouseout', this.mouseOutHandler_
);
- if (!this.resizeHandler_) {
this.resizeHandler_ = function(e) {
dygraph.resize();
};
this.resizeHandler_ = function(e) {
dygraph.resize();
};
@@
-997,9
+999,14
@@
Dygraph.prototype.destroy = function() {
this.registeredEvents_ = [];
// remove mouse event handlers (This may not be necessary anymore)
this.registeredEvents_ = [];
// remove mouse event handlers (This may not be necessary anymore)
- Dygraph.removeEvent(this.mouseEventElement_, 'mouseout', this.mouseOutHandler);
- Dygraph.removeEvent(this.mouseEventElement_, 'mousemove', this.mouseMoveHandler);
+ Dygraph.removeEvent(this.mouseEventElement_, 'mouseout', this.mouseOutHandler
_
);
+ Dygraph.removeEvent(this.mouseEventElement_, 'mousemove', this.mouseMoveHandler
_
);
Dygraph.removeEvent(this.mouseEventElement_, 'mousemove', this.mouseUpHandler_);
Dygraph.removeEvent(this.mouseEventElement_, 'mousemove', this.mouseUpHandler_);
+
+ // remove window handlers
+ Dygraph.removeEvent(window,'resize',this.resizeHandler_);
+ this.resizeHandler_ = null;
+
removeRecursive(this.maindiv_);
var nullOut = function(obj) {
removeRecursive(this.maindiv_);
var nullOut = function(obj) {
@@
-1009,9
+1016,6
@@
Dygraph.prototype.destroy = function() {
}
}
};
}
}
};
- // remove event handlers
- Dygraph.removeEvent(window,'resize',this.resizeHandler_);
- this.resizeHandler_ = null;
// These may not all be necessary, but it can't hurt...
nullOut(this.layout_);
nullOut(this.plotter_);
// These may not all be necessary, but it can't hurt...
nullOut(this.layout_);
nullOut(this.plotter_);