/** * Creates an homogenous object for tracking events so users can know what to expect. * * @class * @namespace PIXI * @param target {object} The target object that the event is called on * @param name {string} The string name of the event that was triggered * @param data {object} Arbitrary event data to pass along */ function Event(target, name, data) { // for duck typing in the ".on()" function this.__isEventObject = true; /** * Tracks the state of bubbling propagation. Do not * set this directly, instead use `event.stopPropagation()` * * @member {boolean} * @private * @readonly */ this.stopped = false; /** * Tracks the state of sibling listener propagation. Do not * set this directly, instead use `event.stopImmediatePropagation()` * * @member {boolean} * @private * @readonly */ this.stoppedImmediate = false; /** * The original target the event triggered on. * * @member {object} * @readonly */ this.target = target; /** * The string name of the event that this represents. * * @member {string} * @readonly */ this.type = name; /** * The data that was passed in with this event. * * @member {object} * @readonly */ this.data = data; /** * The timestamp when the event occurred. * * @member {number} * @readonly */ this.timeStamp = Date.now(); }; /** * Stops the propagation of events up the scene graph (prevents bubbling). * */ Event.prototype.stopPropagation = function stopPropagation() { this.stopped = true; }; /** * Stops the propagation of events to sibling listeners (no longer calls any listeners). * */ Event.prototype.stopImmediatePropagation = function stopImmediatePropagation() { this.stoppedImmediate = true; };