Skip to content

Commit 147e868

Browse files
author
lauren mccarthy
committed
cleaning up mouse and touch cood calls closes #407
1 parent aa73a24 commit 147e868

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

lib/p5.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3053,7 +3053,7 @@ var inputmouse = function (require, core, constants) {
30533053
p5.prototype.mouseIsPressed = false;
30543054
p5.prototype.isMousePressed = false;
30553055
p5.prototype._updateMouseCoords = function (e) {
3056-
if (e.type === 'touchstart' || e.type === 'touchmove') {
3056+
if (e.type === 'touchstart' || e.type === 'touchmove' || e.type === 'touchend') {
30573057
this._setProperty('mouseX', this.touchX);
30583058
this._setProperty('mouseY', this.touchY);
30593059
} else {
@@ -3122,6 +3122,7 @@ var inputmouse = function (require, core, constants) {
31223122
this._setProperty('isMousePressed', true);
31233123
this._setProperty('mouseIsPressed', true);
31243124
this._setMouseButton(e);
3125+
this._updateMouseCoords(e);
31253126
if (typeof context.mousePressed === 'function') {
31263127
executeDefault = context.mousePressed(e);
31273128
if (executeDefault === false) {
@@ -3208,7 +3209,7 @@ var inputtouch = function (require, core) {
32083209
p5.prototype.ptouchY = 0;
32093210
p5.prototype.touches = [];
32103211
p5.prototype._updateTouchCoords = function (e) {
3211-
if (e.type === 'mousedown' || e.type === 'mousemove') {
3212+
if (e.type === 'mousedown' || e.type === 'mousemove' || e.type === 'mouseup') {
32123213
this._setProperty('touchX', this.mouseX);
32133214
this._setProperty('touchY', this.mouseY);
32143215
} else {
@@ -3263,6 +3264,7 @@ var inputtouch = function (require, core) {
32633264
}
32643265
};
32653266
p5.prototype.ontouchend = function (e) {
3267+
this._updateTouchCoords(e);
32663268
var context = this._isGlobal ? window : this;
32673269
var executeDefault;
32683270
if (typeof context.touchEnded === 'function') {

lib/p5.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/input/mouse.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ define(function (require) {
101101
p5.prototype.isMousePressed = false; // both are supported
102102

103103
p5.prototype._updateMouseCoords = function(e) {
104-
if(e.type === 'touchstart' || e.type === 'touchmove') {
104+
if(e.type === 'touchstart' ||
105+
e.type === 'touchmove' ||
106+
e.type === 'touchend') {
105107
this._setProperty('mouseX', this.touchX);
106108
this._setProperty('mouseY', this.touchY);
107109
} else {
@@ -296,6 +298,7 @@ define(function (require) {
296298
this._setProperty('isMousePressed', true);
297299
this._setProperty('mouseIsPressed', true);
298300
this._setMouseButton(e);
301+
this._updateMouseCoords(e);
299302
if (typeof context.mousePressed === 'function') {
300303
executeDefault = context.mousePressed(e);
301304
if(executeDefault === false) {

src/input/touch.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ define(function (require) {
6161
p5.prototype.touches = [];
6262

6363
p5.prototype._updateTouchCoords = function(e) {
64-
if(e.type === 'mousedown' || e.type === 'mousemove'){
64+
if(e.type === 'mousedown' ||
65+
e.type === 'mousemove' ||
66+
e.type === 'mouseup'){
6567
this._setProperty('touchX', this.mouseX);
6668
this._setProperty('touchY', this.mouseY);
6769
} else {
@@ -236,6 +238,7 @@ define(function (require) {
236238
* </div>
237239
*/
238240
p5.prototype.ontouchend = function(e) {
241+
this._updateTouchCoords(e);
239242
var context = this._isGlobal ? window : this;
240243
var executeDefault;
241244
if (typeof context.touchEnded === 'function') {

0 commit comments

Comments
 (0)