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
|
data <o> Event data
|
||||||
*/
|
*/
|
||||||
that.trigger = function(self) {
|
that.trigger = function(self) {
|
||||||
var element = this;
|
var args = arguments, element = this;
|
||||||
if (self.eventHandlers) {
|
self.eventHandlers && setTimeout(function() {
|
||||||
Ox.forEach(Ox.makeObject(Ox.slice(arguments, 1)), function(data, event) {
|
Ox.forEach(Ox.makeObject(Ox.slice(args, 1)), function(data, event) {
|
||||||
var triggered = event.split('.');
|
var triggered = event.split('.');
|
||||||
|
eventHandlers.forEach(function(callback) {
|
||||||
|
callback.call(element, data || {}, event, element);
|
||||||
|
});
|
||||||
triggered.map(function(v, i) {
|
triggered.map(function(v, i) {
|
||||||
return triggered.slice(0, i + 1).join('.');
|
return triggered.slice(0, i + 1).join('.');
|
||||||
}).concat('*').forEach(function(triggered) {
|
}).concat('*').forEach(function(triggered) {
|
||||||
|
@ -133,11 +136,8 @@ Ox.Event = (function() {
|
||||||
handler.callback.call(element, data || {}, event);
|
handler.callback.call(element, data || {}, event);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
eventHandlers.forEach(function(callback) {
|
|
||||||
callback.call(element, data || {}, event, element);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ Ox.Event = (function() {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
eventHandlers = [];
|
eventHandlers = [];
|
||||||
} else if (Ox.isFunction(args[0])) {
|
} else if (Ox.isFunction(args[0])) {
|
||||||
eventHandlers.forEach(function(handler) {
|
eventHandlers.forEach(function(handler, i) {
|
||||||
handler === args[0] && eventHandlers.splice(i, 1);
|
handler === args[0] && eventHandlers.splice(i, 1);
|
||||||
});
|
});
|
||||||
} else if ((self = args.shift()).eventHandlers) {
|
} else if ((self = args.shift()).eventHandlers) {
|
||||||
|
|
Loading…
Reference in a new issue