mirror of
https://github.com/konvajs/konva.git
synced 2025-09-18 18:27:58 +08:00
Merge pull request #328 from thulka/master
Some lines that speed up event handling (20 to 18 % time spent) and make code cleaner.
This commit is contained in:
13
src/Stage.js
13
src/Stage.js
@@ -306,15 +306,10 @@
|
|||||||
var that = this;
|
var that = this;
|
||||||
var events = ['mousedown', 'mousemove', 'mouseup', 'mouseout', 'touchstart', 'touchmove', 'touchend'];
|
var events = ['mousedown', 'mousemove', 'mouseup', 'mouseout', 'touchstart', 'touchmove', 'touchend'];
|
||||||
|
|
||||||
for(var n = 0; n < events.length; n++) {
|
for (var n = 0; n < events.length; n++) {
|
||||||
var pubEvent = events[n];
|
var pubEvent = events[n];
|
||||||
// induce scope
|
var f = that['_' + pubEvent];
|
||||||
( function() {
|
that.content.addEventListener(pubEvent, f.bind(that), false);
|
||||||
var event = pubEvent;
|
|
||||||
that.content.addEventListener(event, function(evt) {
|
|
||||||
that['_' + event](evt);
|
|
||||||
}, false);
|
|
||||||
}());
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_mouseout: function(evt) {
|
_mouseout: function(evt) {
|
||||||
|
Reference in New Issue
Block a user