fix(zoom): initialize gesture state after programmatic zoom #8112
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes an issue where pinch-to-zoom gestures are limited to the default maxRatio (3x) after using programmatic zoom (e.g., double-tap or calling swiper.zoom.in()) without first performing a manual pinch gesture.
Problem:
I want to use this setting:
When users double-tap to zoom before ever pinching, the gesture system's maxRatio is not properly initialized. This causes subsequent pinch gestures to be incorrectly capped at 3x instead of respecting the configured maxRatio or natural image limits.
Root Cause:
The
zoomIn()function sets up gesture.slideEl, gesture.imageEl, and gesture.imageWrapEl, but does not initialize gesture.maxRatio. This causes the checkif (!gesture.slideEl)in onGestureStart() to be skipped on subsequent pinch gestures, preventing proper maxRatio initialization.Solution:
Call
getMaxRatio()inzoomIn()after DOM elements are set up to ensure gesture.maxRatio is properly initialized for programmatic zoom operations.Reproduction:
Fix Verification:
After this fix: