Skip to content

Instantly share code, notes, and snippets.

@ulusoyca
Last active January 23, 2022 21:25
Show Gist options
  • Save ulusoyca/9a9c0df237cd6b88d7e5bf4d8b1ce950 to your computer and use it in GitHub Desktop.
Save ulusoyca/9a9c0df237cd6b88d7e5bf4d8b1ce950 to your computer and use it in GitHub Desktop.
final _scaleStart = 1.1;
final _scaleEnd = 1.0;
double _calculateScale(double currentScrollPosition) {
final startPointInPx = 0.0;
final endPointInPx = heroImageHeight - topBarHeight;
final distanceInPx = endPointInPx - startPointInPx;
final progressInPx = currentScrollPosition - startPointInPx;
final progress = progressInPx / distanceInPx;
final rawScale = _scaleStart - (progress * (_scaleStart - _scaleEnd));
return rawScale.clamp(_scaleEnd, _scaleStart);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment