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;
819
819
820
820
p5 . prototype . _updateNextMouseCoords = function ( e ) {
821
821
if ( this . _curElement !== null && ( ! e . touches || e . touches . length > 0 ) ) {
822
+ this . _updateMouseCoords ( ) ;
823
+
822
824
const mousePos = getMousePos (
823
825
this . _curElement . elt ,
824
826
this . width ,
825
827
this . height ,
826
828
e
827
829
) ;
828
- this . _setProperty ( 'movedX' , e . movementX ) ;
829
- this . _setProperty ( 'movedY' , e . movementY ) ;
830
+
830
831
this . _setProperty ( 'mouseX' , mousePos . x ) ;
831
832
this . _setProperty ( 'mouseY' , mousePos . y ) ;
832
833
this . _setProperty ( 'winMouseX' , mousePos . winX ) ;
833
834
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 ) ;
834
840
}
841
+
835
842
if ( ! this . _hasMouseInteracted ) {
836
- // For first draw, make previous and next equal
837
843
this . _updateMouseCoords ( ) ;
838
844
this . _setProperty ( '_hasMouseInteracted' , true ) ;
839
845
}
You can’t perform that action at this time.
0 commit comments