Skip to content

Conversation

lucadalli
Copy link
Contributor

Updates relevant examples to be in line with the changes to SmoothControls.
Favors simplicity over completeness.
For example: after swiping vertically on the panning example to scroll, it is possible to add a second touch and pan while scrolling. SmoothControls has guards against zoom while scrolling but an unsavory amount of redundancy is necessary to port them to the examples.
To avoid this, we should consider adding an API to allow for user-defined touchModes.

recenter(event.changedTouches[0]);

if (event.cancelable) {
event.preventDefault();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prevents emulation of mouseup event which was invoking recenter a second time.

@@ -247,8 +247,8 @@ <h4>Event listeners can cooperate with camera-controls</h4>
Math.abs(pointer.clientY - startY) > tapDistance)
return;
const rect = modelViewer.getBoundingClientRect();
const x = event.clientX - rect.left;
const y = event.clientY - rect.top;
const x = pointer.clientX - rect.left;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lack of type-checking bit us again. Surprisingly, the browser injects event as a variable in the event handler scope.
Try:
window.addEventListener('click', () => console.log(event))

It was working with mouse events because unlike TouchEvent, MouseEvent has properties clientX and clientY.

Copy link
Contributor

@elalish elalish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spectacular! Those examples both feel great across all my devices now. Thank you!

@elalish elalish merged commit b32bf77 into google:master Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants