mirror of
https://bitbucket.org/bellord13/kit.git
synced 2026-11-13 19:06:11 +03:00
fix
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
/** @module Action */
|
||||
kit.PluginManager.register('Action', function(module, exports, require, global) {
|
||||
|
||||
var support = require('support');
|
||||
|
||||
/**
|
||||
* @memberOf kit
|
||||
*/
|
||||
var Action = function (node, eventName, handler) {
|
||||
this.node = support.getNode(node);
|
||||
this.eventName = eventName;
|
||||
this.handler = function () {
|
||||
if(this.count > -1) {
|
||||
this.count--;
|
||||
if(this.count === -1) {
|
||||
return;
|
||||
}
|
||||
if(this.count === 0) {
|
||||
this.stop();
|
||||
}
|
||||
}
|
||||
handler.apply(this, arguments);
|
||||
}.bind(this);
|
||||
this.count = -1;
|
||||
};
|
||||
Action.prototype.run = function (count = -1) {
|
||||
this.stop();
|
||||
this.count = count;
|
||||
this.node.addEventListener(this.eventName, this.handler, false);
|
||||
};
|
||||
Action.prototype.stop = function () {
|
||||
this.count = -1;
|
||||
this.node.removeEventListener(this.eventName, this.handler, false);
|
||||
};
|
||||
|
||||
return module.exports = Action;
|
||||
});
|
||||
Reference in New Issue
Block a user