src/inputs/touch.js
function(eventName, e) {
                // trigger event on TouchSystem itself
                this.trigger(eventName, e);

                var identifier = e.identifier,
                    closest = e.target,
                    over = this.overs[identifier];

                if (over) {
                    // if old TouchOver target wasn't null, send TouchOut
                    if (
                        (eventName === "TouchMove" && over !== closest) || // if TouchOver target changed
                        eventName === "TouchEnd" ||
                        eventName === "TouchCancel"
                    ) {
                        // or TouchEnd occurred

                        e.eventName = "TouchOut";
                        e.target = over;
                        e.entity = over; // DEPRECATED: remove this in upcoming release
                        over.trigger("TouchOut", e);
                        e.eventName = eventName;
                        e.target = closest;
                        e.entity = closest; // DEPRECATED: remove this in upcoming release

                        // delete old over entity
                        delete this.overs[identifier];
                    }
                }

                // TODO: move routing of events in future to controls system, make it similar to KeyboardSystem
                // try to find closest element that will also receive touch event, whatever the event is
                if (closest) {
                    closest.trigger(eventName, e);
                }

                if (closest) {
                    // if new TouchOver target isn't null, send TouchOver
                    if (
                        eventName === "TouchStart" || // if TouchStart occurred
                        (eventName === "TouchMove" && over !== closest)
                    ) {
                        // or TouchOver target changed

                        e.eventName = "TouchOver";
                        closest.trigger("TouchOver", e);
                        e.eventName = eventName;

                        // save new over entity
                        this.overs[identifier] = closest;
                    }
                }
            }
function(eventName, e) {
                // trigger event on TouchSystem itself
                this.trigger(eventName, e);

                var identifier = e.identifier,
                    closest = e.target,
                    over = this.overs[identifier];

                if (over) {
                    // if old TouchOver target wasn't null, send TouchOut
                    if (
                        (eventName === "TouchMove" && over !== closest) || // if TouchOver target changed
                        eventName === "TouchEnd" ||
                        eventName === "TouchCancel"
                    ) {
                        // or TouchEnd occurred

                        e.eventName = "TouchOut";
                        e.target = over;
                        e.entity = over; // DEPRECATED: remove this in upcoming release
                        over.trigger("TouchOut", e);
                        e.eventName = eventName;
                        e.target = closest;
                        e.entity = closest; // DEPRECATED: remove this in upcoming release

                        // delete old over entity
                        delete this.overs[identifier];
                    }
                }

                // TODO: move routing of events in future to controls system, make it similar to KeyboardSystem
                // try to find closest element that will also receive touch event, whatever the event is
                if (closest) {
                    closest.trigger(eventName, e);
                }

                if (closest) {
                    // if new TouchOver target isn't null, send TouchOver
                    if (
                        eventName === "TouchStart" || // if TouchStart occurred
                        (eventName === "TouchMove" && over !== closest)
                    ) {
                        // or TouchOver target changed

                        e.eventName = "TouchOver";
                        closest.trigger("TouchOver", e);
                        e.eventName = eventName;

                        // save new over entity
                        this.overs[identifier] = closest;
                    }
                }
            }
function ( eventName , e ) { // trigger event on TouchSystem itself this . trigger ( eventName , e ) ; var identifier = e . identifier , closest = e . target , over = this . overs [ identifier ] ; if ( over ) { // if old TouchOver target wasn't null, send TouchOut if ( ( eventName === "TouchMove" && over !== closest ) || // if TouchOver target changed eventName === "TouchEnd" || eventName === "TouchCancel" ) { // or TouchEnd occurred e . eventName = "TouchOut" ; e . target = over ; e . entity = over ; // DEPRECATED: remove this in upcoming release over . trigger ( "TouchOut" , e ) ; e . eventName = eventName ; e . target = closest ; e . entity = closest ; // DEPRECATED: remove this in upcoming release // delete old over entity delete this . overs [ identifier ] ; } } // TODO: move routing of events in future to controls system, make it similar to KeyboardSystem // try to find closest element that will also receive touch event, whatever the event is if ( closest ) { closest . trigger ( eventName , e ) ; } if ( closest ) { // if new TouchOver target isn't null, send TouchOver if ( eventName === "TouchStart" || // if TouchStart occurred ( eventName === "TouchMove" && over !== closest ) ) { // or TouchOver target changed e . eventName = "TouchOver" ; closest . trigger ( "TouchOver" , e ) ; e . eventName = eventName ; // save new over entity this . overs [ identifier ] = closest ; } } }
this method will be called by TouchState iff triggerTouch event was valid
this method will be called by TouchState iff triggerTouch event was valid