diff options
author | Stanley Yip <stanley_yip@brown.edu> | 2020-01-08 13:47:29 -0500 |
---|---|---|
committer | Stanley Yip <stanley_yip@brown.edu> | 2020-01-08 13:47:29 -0500 |
commit | abfa42b6f2cf863deee19aac19328a23687464cb (patch) | |
tree | b481f23ffa7bccbde7a31de34f50d765b6b73162 /src/client/views/Touchable.tsx | |
parent | d8fc218f3481728f221ceacc60ac4bc553f8e295 (diff) | |
parent | 19a71cb2788b9c1c8d8ced4af285bf91033ba626 (diff) |
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into pen
Diffstat (limited to 'src/client/views/Touchable.tsx')
-rw-r--r-- | src/client/views/Touchable.tsx | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/client/views/Touchable.tsx b/src/client/views/Touchable.tsx index 7b0581376..b19984327 100644 --- a/src/client/views/Touchable.tsx +++ b/src/client/views/Touchable.tsx @@ -17,8 +17,8 @@ export abstract class Touchable<T = {}> extends React.Component<T> { @action protected onTouchStart = (e: React.TouchEvent): void => { for (let i = 0; i < e.targetTouches.length; i++) { - let pt: any = e.targetTouches.item(i); - // pen is also a touch, but with a radius of 0.5 (at least with the surface pens). + const pt: any = e.targetTouches.item(i); + // pen is also a touch, but with a radius of 0.5 (at least with the surface pens) // and this seems to be the only way of differentiating pen and touch on touch events if (pt.radiusX > 0.5 && pt.radiusY > 0.5) { this.prevPoints.set(pt.identifier, pt); @@ -42,10 +42,11 @@ export abstract class Touchable<T = {}> extends React.Component<T> { */ @action protected onTouch = (e: TouchEvent): void => { - let myTouches = InteractionUtils.GetMyTargetTouches(e, this.prevPoints); + const myTouches = InteractionUtils.GetMyTargetTouches(e, this.prevPoints); // if we're not actually moving a lot, don't consider it as dragging yet - // if (!InteractionUtils.IsDragging(this.prevPoints, e.targetTouches, 5) && !this._touchDrag) return; + // if (!InteractionUtils.IsDragging(this.prevPoints, myTouches, 5) && !this._touchDrag) return; + console.log(myTouches.length) this._touchDrag = true; switch (myTouches.length) { case 1: @@ -57,7 +58,7 @@ export abstract class Touchable<T = {}> extends React.Component<T> { } for (let i = 0; i < e.targetTouches.length; i++) { - let pt = e.targetTouches.item(i); + const pt = e.targetTouches.item(i); if (pt) { if (this.prevPoints.has(pt.identifier)) { this.prevPoints.set(pt.identifier, pt); @@ -71,9 +72,11 @@ export abstract class Touchable<T = {}> extends React.Component<T> { // console.log(InteractionUtils.GetMyTargetTouches(e, this.prevPoints).length + " up"); // remove all the touches associated with the event for (let i = 0; i < e.changedTouches.length; i++) { - let pt = e.changedTouches.item(i); - if (pt && this.prevPoints.has(pt.identifier)) { - this.prevPoints.delete(pt.identifier); + const pt = e.changedTouches.item(i); + if (pt) { + if (this.prevPoints.has(pt.identifier)) { + this.prevPoints.delete(pt.identifier); + } } } this._touchDrag = false; |