setTimeout before triggering events
This commit is contained in:
parent
d57affea4a
commit
dc438e2427
1 changed files with 8 additions and 8 deletions
|
@ -120,10 +120,13 @@ Ox.Event = (function() {
|
|||
data <o> Event data
|
||||
*/
|
||||
that.trigger = function(self) {
|
||||
var element = this;
|
||||
if (self.eventHandlers) {
|
||||
Ox.forEach(Ox.makeObject(Ox.slice(arguments, 1)), function(data, event) {
|
||||
var args = arguments, element = this;
|
||||
self.eventHandlers && setTimeout(function() {
|
||||
Ox.forEach(Ox.makeObject(Ox.slice(args, 1)), function(data, event) {
|
||||
var triggered = event.split('.');
|
||||
eventHandlers.forEach(function(callback) {
|
||||
callback.call(element, data || {}, event, element);
|
||||
});
|
||||
triggered.map(function(v, i) {
|
||||
return triggered.slice(0, i + 1).join('.');
|
||||
}).concat('*').forEach(function(triggered) {
|
||||
|
@ -133,11 +136,8 @@ Ox.Event = (function() {
|
|||
handler.callback.call(element, data || {}, event);
|
||||
});
|
||||
});
|
||||
eventHandlers.forEach(function(callback) {
|
||||
callback.call(element, data || {}, event, element);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
return that;
|
||||
};
|
||||
|
||||
|
@ -166,7 +166,7 @@ Ox.Event = (function() {
|
|||
if (args.length == 0) {
|
||||
eventHandlers = [];
|
||||
} else if (Ox.isFunction(args[0])) {
|
||||
eventHandlers.forEach(function(handler) {
|
||||
eventHandlers.forEach(function(handler, i) {
|
||||
handler === args[0] && eventHandlers.splice(i, 1);
|
||||
});
|
||||
} else if ((self = args.shift()).eventHandlers) {
|
||||
|
|
Loading…
Reference in a new issue