File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -819,21 +819,27 @@ p5.prototype.mouseIsPressed = false;
819819
820820p5 . prototype . _updateNextMouseCoords = function ( e ) {
821821 if ( this . _curElement !== null && ( ! e . touches || e . touches . length > 0 ) ) {
822+ this . _updateMouseCoords ( ) ;
823+
822824 const mousePos = getMousePos (
823825 this . _curElement . elt ,
824826 this . width ,
825827 this . height ,
826828 e
827829 ) ;
828- this . _setProperty ( 'movedX' , e . movementX ) ;
829- this . _setProperty ( 'movedY' , e . movementY ) ;
830+
830831 this . _setProperty ( 'mouseX' , mousePos . x ) ;
831832 this . _setProperty ( 'mouseY' , mousePos . y ) ;
832833 this . _setProperty ( 'winMouseX' , mousePos . winX ) ;
833834 this . _setProperty ( 'winMouseY' , mousePos . winY ) ;
835+
836+ const deltaX = this . mouseX - this . pmouseX ;
837+ const deltaY = this . mouseY - this . pmouseY ;
838+ this . _setProperty ( 'movedX' , deltaX ) ;
839+ this . _setProperty ( 'movedY' , deltaY ) ;
834840 }
841+
835842 if ( ! this . _hasMouseInteracted ) {
836- // For first draw, make previous and next equal
837843 this . _updateMouseCoords ( ) ;
838844 this . _setProperty ( '_hasMouseInteracted' , true ) ;
839845 }
You can’t perform that action at this time.
0 commit comments