mirror of
https://github.com/immich-app/immich.git
synced 2025-12-17 17:23:20 +03:00
fix(mobile): pinch + move scale (#21332)
* fix: pinch + move scale * added lost changes from #18744
This commit is contained in:
@@ -121,7 +121,6 @@ class PhotoViewCore extends StatefulWidget {
|
|||||||
|
|
||||||
class PhotoViewCoreState extends State<PhotoViewCore>
|
class PhotoViewCoreState extends State<PhotoViewCore>
|
||||||
with TickerProviderStateMixin, PhotoViewControllerDelegate, HitCornersDetector {
|
with TickerProviderStateMixin, PhotoViewControllerDelegate, HitCornersDetector {
|
||||||
Offset? _normalizedPosition;
|
|
||||||
double? _scaleBefore;
|
double? _scaleBefore;
|
||||||
double? _rotationBefore;
|
double? _rotationBefore;
|
||||||
|
|
||||||
@@ -154,7 +153,6 @@ class PhotoViewCoreState extends State<PhotoViewCore>
|
|||||||
void onScaleStart(ScaleStartDetails details) {
|
void onScaleStart(ScaleStartDetails details) {
|
||||||
_rotationBefore = controller.rotation;
|
_rotationBefore = controller.rotation;
|
||||||
_scaleBefore = scale;
|
_scaleBefore = scale;
|
||||||
_normalizedPosition = details.focalPoint - controller.position;
|
|
||||||
_scaleAnimationController.stop();
|
_scaleAnimationController.stop();
|
||||||
_positionAnimationController.stop();
|
_positionAnimationController.stop();
|
||||||
_rotationAnimationController.stop();
|
_rotationAnimationController.stop();
|
||||||
@@ -166,8 +164,14 @@ class PhotoViewCoreState extends State<PhotoViewCore>
|
|||||||
};
|
};
|
||||||
|
|
||||||
void onScaleUpdate(ScaleUpdateDetails details) {
|
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 double newScale = _scaleBefore! * details.scale;
|
||||||
Offset delta = details.focalPoint - _normalizedPosition!;
|
final double scaleDelta = newScale / scale;
|
||||||
|
final Offset newPosition =
|
||||||
|
(controller.position + details.focalPointDelta) * scaleDelta - centeredFocalPoint * (scaleDelta - 1);
|
||||||
|
|
||||||
updateScaleStateFromNewScale(newScale);
|
updateScaleStateFromNewScale(newScale);
|
||||||
|
|
||||||
@@ -176,7 +180,7 @@ class PhotoViewCoreState extends State<PhotoViewCore>
|
|||||||
|
|
||||||
updateMultiple(
|
updateMultiple(
|
||||||
scale: newScale,
|
scale: newScale,
|
||||||
position: panEnabled ? delta : clampPosition(position: delta * details.scale),
|
position: panEnabled ? newPosition : clampPosition(position: newPosition),
|
||||||
rotation: rotationEnabled ? _rotationBefore! + details.rotation : null,
|
rotation: rotationEnabled ? _rotationBefore! + details.rotation : null,
|
||||||
rotationFocusPoint: rotationEnabled ? details.focalPoint : null,
|
rotationFocusPoint: rotationEnabled ? details.focalPoint : null,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user