@@ -459,13 +459,22 @@ var Pointer = new Class({
459459 this . active = ( id === 0 ) ? true : false ;
460460
461461 /**
462- * Time when this Pointer was most recently updated by the Game step .
462+ * Time when this Pointer was most recently updated by a DOM Event .
463463 *
464464 * @name Phaser.Input.Pointer#time
465465 * @type {number }
466466 * @since 3.16.0
467467 */
468468 this . time = 0 ;
469+
470+ /**
471+ * The game frame when this Pointer was most recently updated by a DOM Event.
472+ *
473+ * @name Phaser.Input.Pointer#lastAction
474+ * @type {integer }
475+ * @since 3.18.0
476+ */
477+ this . lastAction = - 1 ;
469478 } ,
470479
471480 /**
@@ -495,16 +504,24 @@ var Pointer = new Class({
495504 */
496505 reset : function ( time )
497506 {
498- this . dirty = false ;
507+ var currentFrame = this . manager . game . loop . frame ;
499508
500- this . justDown = false ;
501- this . justUp = false ;
502- this . justMoved = false ;
509+ if ( this . lastAction < currentFrame )
510+ {
511+ // There was a DOM Event just prior to the game step
512+ this . dirty = false ;
503513
504- this . time = time ;
514+ this . justDown = false ;
515+ this . justUp = false ;
516+ this . justMoved = false ;
505517
506- this . movementX = 0 ;
507- this . movementY = 0 ;
518+ this . time = time ;
519+
520+ this . movementX = 0 ;
521+ this . movementY = 0 ;
522+
523+ this . lastAction = currentFrame ;
524+ }
508525 } ,
509526
510527 /**
@@ -563,10 +580,17 @@ var Pointer = new Class({
563580 * @since 3.0.0
564581 *
565582 * @param {MouseEvent } event - The Mouse Event to process.
566- * @param {integer } time - The current timestamp as generated by the Request Animation Frame or SetTimeout.
567583 */
568- up : function ( event , time )
584+ up : function ( event )
569585 {
586+ var time = event . timeStamp ;
587+ var currentFrame = this . manager . game . loop . frame ;
588+
589+ if ( currentFrame > this . lastAction )
590+ {
591+ this . reset ( time ) ;
592+ }
593+
570594 if ( 'buttons' in event )
571595 {
572596 this . buttons = event . buttons ;
@@ -604,10 +628,17 @@ var Pointer = new Class({
604628 * @since 3.0.0
605629 *
606630 * @param {MouseEvent } event - The Mouse Event to process.
607- * @param {integer } time - The current timestamp as generated by the Request Animation Frame or SetTimeout.
608631 */
609- down : function ( event , time )
632+ down : function ( event )
610633 {
634+ var time = event . timeStamp ;
635+ var currentFrame = this . manager . game . loop . frame ;
636+
637+ if ( currentFrame > this . lastAction )
638+ {
639+ this . reset ( time ) ;
640+ }
641+
611642 if ( 'buttons' in event )
612643 {
613644 this . buttons = event . buttons ;
@@ -645,10 +676,17 @@ var Pointer = new Class({
645676 * @since 3.0.0
646677 *
647678 * @param {MouseEvent } event - The Mouse Event to process.
648- * @param {integer } time - The current timestamp as generated by the Request Animation Frame or SetTimeout.
649679 */
650- move : function ( event , time )
680+ move : function ( event )
651681 {
682+ var time = event . timeStamp ;
683+ var currentFrame = this . manager . game . loop . frame ;
684+
685+ if ( currentFrame > this . lastAction )
686+ {
687+ this . reset ( time ) ;
688+ }
689+
652690 if ( 'buttons' in event )
653691 {
654692 this . buttons = event . buttons ;
0 commit comments