mirror of
https://github.com/immich-app/immich
synced 2025-06-06 20:58:30 +00:00
fix: pinch zoom in mobile app (#18744)
* Change photo zoom logic To properly zoom to current position and pan at the correct speed TODO: zoom to current pinch position * zoom to current pinch position * Clean unused variable * Formatting * fix: lint --------- Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
parent
1f18a09061
commit
0e81c20cbb
@ -120,7 +120,6 @@ class PhotoViewCoreState extends State<PhotoViewCore>
|
||||
TickerProviderStateMixin,
|
||||
PhotoViewControllerDelegate,
|
||||
HitCornersDetector {
|
||||
Offset? _normalizedPosition;
|
||||
double? _scaleBefore;
|
||||
double? _rotationBefore;
|
||||
|
||||
@ -153,23 +152,29 @@ class PhotoViewCoreState extends State<PhotoViewCore>
|
||||
void onScaleStart(ScaleStartDetails details) {
|
||||
_rotationBefore = controller.rotation;
|
||||
_scaleBefore = scale;
|
||||
_normalizedPosition = details.focalPoint - controller.position;
|
||||
_scaleAnimationController.stop();
|
||||
_positionAnimationController.stop();
|
||||
_rotationAnimationController.stop();
|
||||
}
|
||||
|
||||
void onScaleUpdate(ScaleUpdateDetails details) {
|
||||
final centeredFocalPoint = Offset(
|
||||
details.focalPoint.dx - scaleBoundaries.outerSize.width / 2,
|
||||
details.focalPoint.dy - scaleBoundaries.outerSize.height / 2,
|
||||
);
|
||||
final double newScale = _scaleBefore! * details.scale;
|
||||
final Offset delta = details.focalPoint - _normalizedPosition!;
|
||||
final double scaleDelta = newScale / scale;
|
||||
final Offset newPosition =
|
||||
(controller.position + details.focalPointDelta) * scaleDelta -
|
||||
centeredFocalPoint * (scaleDelta - 1);
|
||||
|
||||
updateScaleStateFromNewScale(newScale);
|
||||
|
||||
updateMultiple(
|
||||
scale: newScale,
|
||||
position: widget.enablePanAlways
|
||||
? delta
|
||||
: clampPosition(position: delta, scale: details.scale),
|
||||
? newPosition
|
||||
: clampPosition(position: newPosition),
|
||||
rotation:
|
||||
widget.enableRotation ? _rotationBefore! + details.rotation : null,
|
||||
rotationFocusPoint: widget.enableRotation ? details.focalPoint : null,
|
||||
|
Loading…
x
Reference in New Issue
Block a user