Skip to content

feat: add scaleSmoothing option for smoother pinch-zoom gestures #684

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

enhancer13
Copy link

@enhancer13 enhancer13 commented Apr 20, 2025

PR Checklist

Please review the guidelines for contributing to this repository.

  • I am requesting to pull a topic/feature/bugfix branch (right side). In other words, not main.
  • I have run npm test against my changes and tests pass.
  • I have added tests to prove my fix is effective or my feature works. This can be done in the form of unit tests in test/unit/ or a new or altered demo in demo/.
  • I have added or edited necessary types and generated documentation (npm run docs), or no docs changes are needed.

Description

This PR introduces a new scaleSmoothing option to address visual instability during rapid pinch-zoom gestures on mobile devices.

Problem: Fast pinch gestures on touchscreens caused trembling/jittering due to immediate scale changes between gesture events. Existing animation options weren't suitable for real-time gesture handling.
before_fix

  { scale: 1.253061, positions: [100,100,150,100] }, // +25.3%
  { scale: 1.175761, positions: [100,100,145,100] }, // -6.2%
  { scale: 0.947083, positions: [100,100,130,100] }, // -24.3% 
  { scale: 1.055873, positions: [100,100,140,100] }, // +11.5%
  { scale: 0.990737, positions: [100,100,135,100] }  // -6.5%

Solution:

  • Implement frame blending using smoothing factor (0-1)
  • scaleSmoothing: 0 - Immediate scale changes (existing behavior)
  • scaleSmoothing: 0.5 - Blends 50% of new scale with 50% previous scale
    after_fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant