Skip to content

Commit 0405832

Browse files
author
Lauren McCarthy
committed
sort of fixes to mouse and touch
1 parent b76848b commit 0405832

File tree

3 files changed

+13
-26
lines changed

3 files changed

+13
-26
lines changed

src/core/p5.Element.js

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,7 @@ p5.Element.prototype.class = function(c) {
188188
*/
189189
p5.Element.prototype.mousePressed = function (fxn) {
190190
attachListener('mousedown', fxn, this);
191-
if (!window.PointerEvent) {
192-
attachListener('touchstart', fxn, this);
193-
}
191+
attachListener('touchstart', fxn, this);
194192
return this;
195193
};
196194

@@ -305,9 +303,7 @@ p5.Element.prototype.mouseWheel = function (fxn) {
305303
*/
306304
p5.Element.prototype.mouseReleased = function (fxn) {
307305
attachListener('mouseup', fxn, this);
308-
if (!window.PointerEvent) {
309-
attachListener('touchend', fxn, this);
310-
}
306+
attachListener('touchend', fxn, this);
311307
return this;
312308
};
313309

@@ -414,9 +410,7 @@ p5.Element.prototype.mouseClicked = function (fxn) {
414410
*/
415411
p5.Element.prototype.mouseMoved = function (fxn) {
416412
attachListener('mousemove', fxn, this);
417-
if (!window.PointerEvent) {
418-
attachListener('touchmove', fxn, this);
419-
}
413+
attachListener('touchmove', fxn, this);
420414
return this;
421415
};
422416

@@ -644,9 +638,7 @@ p5.Element.prototype.mouseOut = function (fxn) {
644638
*/
645639
p5.Element.prototype.touchStarted = function (fxn) {
646640
attachListener('touchstart', fxn, this);
647-
if (!window.PointerEvent) {
648-
attachListener('mousedown', fxn, this);
649-
}
641+
attachListener('mousedown', fxn, this);
650642
return this;
651643
};
652644

@@ -685,9 +677,7 @@ p5.Element.prototype.touchStarted = function (fxn) {
685677
*/
686678
p5.Element.prototype.touchMoved = function (fxn) {
687679
attachListener('touchmove', fxn, this);
688-
if (!window.PointerEvent) {
689-
attachListener('mousemove', fxn, this);
690-
}
680+
attachListener('mousemove', fxn, this);
691681
return this;
692682
};
693683

@@ -735,9 +725,7 @@ p5.Element.prototype.touchMoved = function (fxn) {
735725
*/
736726
p5.Element.prototype.touchEnded = function (fxn) {
737727
attachListener('touchend', fxn, this);
738-
if (!window.PointerEvent) {
739-
attachListener('mouseup', fxn, this);
740-
}
728+
attachListener('mouseup', fxn, this);
741729
return this;
742730
};
743731

src/events/mouse.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ p5.prototype.mouseButton = 0;
350350
*
351351
*/
352352
p5.prototype.mouseIsPressed = false;
353-
p5.prototype.isMousePressed = false; // both are supported
354353

355354
p5.prototype._updateNextMouseCoords = function(e) {
356355
if(this._curElement !== null && (!e.touches || e.touches.length>0)) {
@@ -496,7 +495,7 @@ p5.prototype._onmousemove = function(e){
496495
var context = this._isGlobal ? window : this;
497496
var executeDefault;
498497
this._updateNextMouseCoords(e);
499-
if (!this.isMousePressed) {
498+
if (!this.mouseIsPressed) {
500499
if (typeof context.mouseMoved === 'function') {
501500
executeDefault = context.mouseMoved(e);
502501
if(executeDefault === false) {
@@ -510,7 +509,7 @@ p5.prototype._onmousemove = function(e){
510509
if(executeDefault === false) {
511510
e.preventDefault();
512511
}
513-
} else if (!window.PointerEvent && typeof context.touchMoved === 'function') {
512+
} else if (typeof context.touchMoved === 'function') {
514513
executeDefault = context.touchMoved(e);
515514
if(executeDefault === false) {
516515
e.preventDefault();
@@ -577,7 +576,7 @@ p5.prototype._onmousedown = function(e) {
577576
if(executeDefault === false) {
578577
e.preventDefault();
579578
}
580-
} else if (!window.PointerEvent && typeof context.touchStarted === 'function') {
579+
} else if (typeof context.touchStarted === 'function') {
581580
executeDefault = context.touchStarted(e);
582581
if(executeDefault === false) {
583582
e.preventDefault();
@@ -641,7 +640,7 @@ p5.prototype._onmouseup = function(e) {
641640
if(executeDefault === false) {
642641
e.preventDefault();
643642
}
644-
} else if (!window.PointerEvent && typeof context.touchEnded === 'function') {
643+
} else if (typeof context.touchEnded === 'function') {
645644
executeDefault = context.touchEnded(e);
646645
if(executeDefault === false) {
647646
e.preventDefault();

src/events/touch.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ p5.prototype._ontouchstart = function(e) {
104104
if(executeDefault === false) {
105105
e.preventDefault();
106106
}
107-
} else if (!window.PointerEvent && typeof context.mousePressed === 'function') {
107+
} else if (typeof context.mousePressed === 'function') {
108108
executeDefault = context.mousePressed(e);
109109
if(executeDefault === false) {
110110
e.preventDefault();
@@ -166,7 +166,7 @@ p5.prototype._ontouchmove = function(e) {
166166
if(executeDefault === false) {
167167
e.preventDefault();
168168
}
169-
} else if (!window.PointerEvent && typeof context.mouseDragged === 'function') {
169+
} else if (typeof context.mouseDragged === 'function') {
170170
executeDefault = context.mouseDragged(e);
171171
if(executeDefault === false) {
172172
e.preventDefault();
@@ -230,7 +230,7 @@ p5.prototype._ontouchend = function(e) {
230230
if(executeDefault === false) {
231231
e.preventDefault();
232232
}
233-
} else if (!window.PointerEvent && typeof context.mouseReleased === 'function') {
233+
} else if (typeof context.mouseReleased === 'function') {
234234
executeDefault = context.mouseReleased(e);
235235
if(executeDefault === false) {
236236
e.preventDefault();

0 commit comments

Comments
 (0)