@ -120,7 +120,6 @@ class PhotoViewCoreState extends State<PhotoViewCore>
TickerProviderStateMixin ,
TickerProviderStateMixin ,
PhotoViewControllerDelegate ,
PhotoViewControllerDelegate ,
HitCornersDetector {
HitCornersDetector {
Offset ? _normalizedPosition ;
double ? _scaleBefore ;
double ? _scaleBefore ;
double ? _rotationBefore ;
double ? _rotationBefore ;
@ -153,23 +152,29 @@ 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 ( ) ;
}
}
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 ;
final 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 ) ;
updateMultiple (
updateMultiple (
scale: newScale ,
scale: newScale ,
position: widget . enablePanAlways
position: widget . enablePanAlways
? delta
? newPosition
: clampPosition ( position: delta, scale: details . scale ) ,
: clampPosition ( position: newPosition ) ,
rotation:
rotation:
widget . enableRotation ? _rotationBefore ! + details . rotation : null ,
widget . enableRotation ? _rotationBefore ! + details . rotation : null ,
rotationFocusPoint: widget . enableRotation ? details . focalPoint : null ,
rotationFocusPoint: widget . enableRotation ? details . focalPoint : null ,