File tree Expand file tree Collapse file tree 3 files changed +10
-14
lines changed Expand file tree Collapse file tree 3 files changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -205,6 +205,7 @@ class p5 {
205
205
} ;
206
206
this . _millisStart = - 1 ;
207
207
this . _recording = false ;
208
+ this . touchstart = false ;
208
209
this . touchend = false ;
209
210
210
211
// States used in the custom random generators
Original file line number Diff line number Diff line change @@ -657,21 +657,24 @@ p5.prototype._onmousedown = function(e) {
657
657
this . _setMouseButton ( e ) ;
658
658
this . _updateNextMouseCoords ( e ) ;
659
659
660
+ // _ontouchstart triggers first and sets this.touchstart
661
+ if ( this . touchstart ) {
662
+ return ;
663
+ }
664
+
660
665
if ( typeof context . mousePressed === 'function' ) {
661
666
executeDefault = context . mousePressed ( e ) ;
662
667
if ( executeDefault === false ) {
663
668
e . preventDefault ( ) ;
664
669
}
665
- // only safari needs this manual fallback for consistency
666
- } else if (
667
- navigator . userAgent . toLowerCase ( ) . includes ( 'safari' ) &&
668
- typeof context . touchStarted === 'function'
669
- ) {
670
+ } else if ( typeof context . touchStarted === 'function' ) {
670
671
executeDefault = context . touchStarted ( e ) ;
671
672
if ( executeDefault === false ) {
672
673
e . preventDefault ( ) ;
673
674
}
674
675
}
676
+
677
+ this . touchstart = false ;
675
678
} ;
676
679
677
680
/**
Original file line number Diff line number Diff line change @@ -134,15 +134,7 @@ p5.prototype._ontouchstart = function(e) {
134
134
if ( executeDefault === false ) {
135
135
e . preventDefault ( ) ;
136
136
}
137
- // only safari needs this manual fallback for consistency
138
- } else if (
139
- navigator . userAgent . toLowerCase ( ) . includes ( 'safari' ) &&
140
- typeof context . mousePressed === 'function'
141
- ) {
142
- executeDefault = context . mousePressed ( e ) ;
143
- if ( executeDefault === false ) {
144
- e . preventDefault ( ) ;
145
- }
137
+ this . touchstart = true ;
146
138
}
147
139
} ;
148
140
You can’t perform that action at this time.
0 commit comments