Skip to content

Conversation

@mcyph
Copy link
Collaborator

@mcyph mcyph commented Nov 30, 2022

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.

@mcyph mcyph marked this pull request as draft December 5, 2022 10:47
@mcyph mcyph requested a review from csouchet December 5, 2022 10:58
@tbouffard tbouffard added the enhancement New feature or request label Dec 3, 2023
@tbouffard tbouffard changed the base branch from development to main February 15, 2024 09:17
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);
Copy link
Member

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) => {
Copy link
Member

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 => {
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pinch zoom not working

2 participants