onScaleAnimate method
Handle inertia scale animation.
Implementation
@protected
void onScaleAnimate() {
if (!scaleController.isAnimating) {
currentAxis = null;
scaleAnimation?.removeListener(onScaleAnimate);
scaleAnimation = null;
scaleController.reset();
afterAnimate();
return;
}
final double desiredScale = scaleAnimation!.value;
final double scaleChange =
desiredScale / transformationController!.value.getScaleOnZAxis();
final Offset referenceFocalPoint = transformationController!.toScene(
scaleAnimationFocalPoint,
);
transformationController!.value = matrixScale(
transformationController!.value,
scaleChange,
);
// While scaling, translate such that the user's two fingers stay on
// the same places in the scene. That means that the focal point of
// the scale should be on the same place in the scene before and after
// the scale.
final Offset focalPointSceneScaled = transformationController!.toScene(
scaleAnimationFocalPoint,
);
transformationController!.value = matrixTranslate(
transformationController!.value,
focalPointSceneScaled - referenceFocalPoint,
);
}