0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-11-27 09:50:52 -05:00

Events.clear is now Events.off

This commit is contained in:
liabru 2014-03-24 19:49:03 +00:00
parent b253683cb5
commit aa42f1653f

View file

@ -28,9 +28,27 @@ var Events = {};
}
};
/**
* Clears all callbacks for the given event names if supplied, otherwise all events
* @method off
* @param {} object
* @param {string} eventNames
*/
Events.off = function(object, eventNames) {
if (!eventNames) {
object.events = {};
return;
}
var names = eventNames.split(' ');
for (var i = 0; i < names.length; i++) {
object.events[names[i]] = [];
}
};
/**
* Fires all the callbacks subscribed to the given object's eventName, in the order they subscribed, if any
* @method fire
* @method trigger
* @param {} object
* @param {string} eventNames
* @param {} event
@ -64,22 +82,4 @@ var Events = {};
}
};
/**
* Clears all callbacks for the given event names if supplied, otherwise all events
* @method clear
* @param {} object
* @param {string} eventNames
*/
Events.clear = function(object, eventNames) {
if (!eventNames) {
object.events = {};
return;
}
var names = eventNames.split(' ');
for (var i = 0; i < names.length; i++) {
object.events[names[i]] = [];
}
};
})();