Skip to content

Instantly share code, notes, and snippets.

@AlShevelev
Last active November 29, 2023 18:41
Show Gist options
  • Save AlShevelev/d24fe28ae8bf3d6bee155fa1db53f9c5 to your computer and use it in GitHub Desktop.
Save AlShevelev/d24fe28ae8bf3d6bee155fa1db53f9c5 to your computer and use it in GitHub Desktop.
@override
void onScaleStart(ScaleStartInfo info) {
_startZoom = camera.viewfinder.zoom;
}
@override
void onScaleUpdate(ScaleUpdateInfo info) {
if (currentScale.isIdentity()) {
_processDrag(info);
}
}
void _processDrag(ScaleUpdateInfo info) {
final delta = info.delta.global;
final zoomDragFactor = 1.0 / _startZoom;
final currentPosition = camera.viewfinder.position;
camera.viewfinder.position = currentPosition.translated(
-delta.x * zoomDragFactor,
-delta.y * zoomDragFactor,
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment