Last active
January 23, 2022 21:25
-
-
Save ulusoyca/9a9c0df237cd6b88d7e5bf4d8b1ce950 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
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