diff options
author | Stanley Yip <stanley_yip@brown.edu> | 2019-11-23 17:56:43 -0500 |
---|---|---|
committer | Stanley Yip <stanley_yip@brown.edu> | 2019-11-23 17:56:43 -0500 |
commit | 80ecf02d19efb4cc2de63b77f4aa821bd74c67b2 (patch) | |
tree | c64fd79dafd83095b84d6107c19df2c2104355a0 /src/client/util/InteractionUtils.ts | |
parent | 22472e278c5616ba86c75ed29cd5846d0cf35ff5 (diff) |
tool bar works better with touch, started doing resizing interaction but not done
Diffstat (limited to 'src/client/util/InteractionUtils.ts')
-rw-r--r-- | src/client/util/InteractionUtils.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/client/util/InteractionUtils.ts b/src/client/util/InteractionUtils.ts index d5799c21f..b7738e862 100644 --- a/src/client/util/InteractionUtils.ts +++ b/src/client/util/InteractionUtils.ts @@ -56,6 +56,29 @@ export namespace InteractionUtils { return 0; } + /** + * Returns -1 if pinning and pinching out, 0 if not pinning, and 1 if pinching in + * @param pt1 - new point that corresponds to oldPoint1 + * @param pt2 - new point that corresponds to oldPoint2 + * @param oldPoint1 - previous point 1 + * @param oldPoint2 - previous point 2 + */ + export function Pinning(pt1: React.Touch, pt2: React.Touch, oldPoint1: React.Touch, oldPoint2: React.Touch): number { + let threshold = 4; + + let pt1Dist = TwoPointEuclidist(oldPoint1, pt1); + let pt2Dist = TwoPointEuclidist(oldPoint2, pt2); + + let pinching = Pinching(pt1, pt2, oldPoint1, oldPoint2); + + if (pinching !== 0) { + if ((pt1Dist < threshold && pt2Dist > threshold) || (pt1Dist > threshold && pt2Dist < threshold)) { + return pinching; + } + } + return 0; + } + // These might not be very useful anymore, but I'll leave them here for now -syip2 { |