Created
November 25, 2023 19:46
-
-
Save AlShevelev/7a89cc076d997057ced58bcb4c66fb9c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@override | |
void onScaleUpdate(ScaleUpdateInfo info) { | |
final currentScale = info.scale.global; | |
if (currentScale.isIdentity()) { | |
_processDrag(info); | |
} else { | |
_processScale(info, currentScale); | |
} | |
} | |
void _processScale(ScaleUpdateInfo info, Vector2 currentScale) { | |
final newZoom = _startZoom * ((currentScale.y + currentScale.x) / 2.0); | |
camera.viewfinder.zoom = newZoom.clamp(_minZoom, _maxZoom); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment