Skip to content

Commit 237e600

Browse files
committed
Simplify implementation
1 parent 14681f4 commit 237e600

File tree

1 file changed

+3
-27
lines changed

1 file changed

+3
-27
lines changed

src/data.js

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,17 @@ function addData(p5, fn){
99
return this.mouseDragged(...args);
1010
};
1111
p5.Element.prototype.touchStarted = function (cb) {
12-
if (cb === false) {
13-
return this.mousePressed(false);
14-
}
15-
return this.mousePressed(function (event) {
16-
if (this._hasTouchMoveHandler) {
17-
this._pointers = this._pointers || {};
18-
this._pointers[event.pointerId] = true;
19-
}
20-
event.target.setPointerCapture(event.pointerId);
21-
return cb(event);
22-
});
12+
return this.mousePressed(cb);
2313
};
2414
p5.Element.prototype.touchEnded = function (cb) {
25-
if (cb === false) {
26-
return this.mouseReleased(false);
27-
}
28-
return this.mouseReleased(function (event) {
29-
if (this._hasTouchMoveHandler) {
30-
this._pointers = this._pointers || {};
31-
if (this._pointers[event.pointerId]) {
32-
event.target.releasePointerCapture(event.pointerId);
33-
delete this._pointers[event.pointerId];
34-
}
35-
}
36-
return cb(event);
37-
});
15+
return this.mouseReleased(cb);
3816
};
3917
p5.Element.prototype.touchMoved = function (cb) {
4018
if (cb === false) {
41-
this._hasTouchMoveHandler = false;
4219
return this.mouseMoved(false);
4320
}
44-
this._hasTouchMoveHandler = true;
4521
return this.mouseMoved(function (event) {
46-
if (Object.keys(this._pointers || {}).length > 0) {
22+
if ((event.buttons & 1) !== 0) {
4723
return cb(event);
4824
}
4925
});

0 commit comments

Comments
 (0)