-
Notifications
You must be signed in to change notification settings - Fork 199
New pinch touch zoom [draft] #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ler to allow use in touch story example
…made it so mousemove/pointermove events are ignored when there's multitouch and addMouseWheelListener enabled
| const getTouchDistance = (touches: TouchArray) => { | ||
| const a = touches[0].clientX - touches[1].clientX; | ||
| const b = touches[0].clientY - touches[1].clientY; | ||
| return Math.sqrt(a * a + b * b); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: use Math.hypot instead (perform the same calculation)
|
|
||
| InternalEvent.addListener(target, 'gesturechange', ((evt: GestureEvent) => { | ||
| InternalEvent.consume(evt); | ||
| const getTouchDistance = (touches: TouchArray) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: move this closure out of the enclosing function as it doesn't depend on any state provided by this function
|
|
||
| if (typeof evt.scale === 'number') { | ||
| const diff = scale - evt.scale; | ||
| const touchesToArray = (touches: TouchList): TouchArray => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: move this closure out of the enclosing function as getTouchDistance.
Summary
Fixes jumpy multitouch zooming on Android, and restores the touch example by converting it to StoryBook and ES6 classes.
More details/caveats of this PR are in the comment at #62 (comment).
Description for the changelog
Resolves #62.