@@ -249,6 +249,21 @@ Phaser.Pointer = function (game, id) {
249249 this . isMouse = true ;
250250 }
251251
252+ /**
253+ * Click trampolines associated with this pointer. See `addClickTrampoline`.
254+ * @property {object[]|null } _clickTrampolines
255+ * @private
256+ */
257+ this . _clickTrampolines = null ;
258+
259+ /**
260+ * When the Pointer has click trampolines the last target object is stored here
261+ * so it can be used to check for validity of the trampoline in a post-Up/'stop'.
262+ * @property {object } _trampolineTargetObject
263+ * @private
264+ */
265+ this . _trampolineTargetObject = null ;
266+
252267} ;
253268
254269Phaser . Pointer . prototype = {
@@ -279,6 +294,8 @@ Phaser.Pointer.prototype = {
279294 this . isDown = true ;
280295 this . isUp = false ;
281296 this . dirty = false ;
297+ this . _clickTrampolines = null ;
298+ this . _trampolineTargetObject = null ;
282299
283300 // Work out how long it has been since the last click
284301 this . msSinceLastClick = this . game . time . now - this . timeDown ;
@@ -631,6 +648,10 @@ Phaser.Pointer.prototype = {
631648
632649 this . game . input . interactiveItems . callAll ( '_releasedHandler' , this ) ;
633650
651+ if ( this . _clickTrampolines )
652+ {
653+ this . _trampolineTargetObject = this . targetObject ;
654+ }
634655 this . targetObject = null ;
635656
636657 return this ;
@@ -669,6 +690,78 @@ Phaser.Pointer.prototype = {
669690
670691 } ,
671692
693+ /**
694+ * Add a click trampoline to this pointer.
695+ *
696+ * A click trampoline is a callback that is run on the DOM 'click' event; this is primarily
697+ * needed with certain browsers (ie. IE11) which restrict some actions like requestFullscreen
698+ * to the DOM 'click' event and reject it for 'pointer*'' and 'mouseup*'' events.
699+ *
700+ * This is used internally by the ScaleManager; click trampoline usage is uncommon.
701+ *
702+ * @method Phaser.Pointer#addClickTrampoline
703+ * @protected
704+ * @param {string } name - The name of the trampoline; must be unique among active trampolines in this pointer.
705+ * @param {function } callback - Callback to run/trampoline.
706+ * @param {object } callbackContext - Context of the callback.
707+ * @param {object[]|null } callbackArgs - Additional callback args, if any. Supplied as an array.
708+ */
709+ addClickTrampoline : function ( name , callback , callbackContext , callbackArgs ) {
710+
711+ if ( ! this . isDown )
712+ {
713+ return ;
714+ }
715+
716+ var trampolines = ( this . _clickTrampolines = this . _clickTrampolines || [ ] ) ;
717+
718+ for ( var i = 0 ; i < trampolines . length ; i ++ )
719+ {
720+ if ( trampolines [ i ] . name === name )
721+ {
722+ trampolines . splice ( i , 1 ) ;
723+ break ;
724+ }
725+ }
726+
727+ trampolines . push ( {
728+ name : name ,
729+ targetObject : this . targetObject ,
730+ callback : callback ,
731+ callbackContext : callbackContext ,
732+ callbackArgs : callbackArgs
733+ } ) ;
734+
735+ } ,
736+
737+ /**
738+ * Fire all click trampolines for which the pointers are still refering to the registered object.
739+ * @method Phaser.Pointer#processClickTrampolines
740+ * @private
741+ */
742+ processClickTrampolines : function ( ) {
743+
744+ var trampolines = this . _clickTrampolines ;
745+ if ( ! trampolines )
746+ {
747+ return ;
748+ }
749+
750+ for ( var i = 0 ; i < trampolines . length ; i ++ )
751+ {
752+ var trampoline = trampolines [ i ] ;
753+
754+ if ( trampoline . targetObject === this . _trampolineTargetObject )
755+ {
756+ trampoline . callback . apply ( trampoline . callbackContext , trampoline . callbackArgs ) ;
757+ }
758+ }
759+
760+ this . _clickTrampolines = null ;
761+ this . _trampolineTargetObject = null ;
762+
763+ } ,
764+
672765 /**
673766 * Resets the Pointer properties. Called by InputManager.reset when you perform a State change.
674767 * @method Phaser.Pointer#reset
0 commit comments