π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Improve auto-scroll intensity with optimized exponential formula
ashilkn21e4e32840a0
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/swipe_selection_wrapper.dart b/mobile/apps/photos/lib/ui/viewer/gallery/swipe_selection_wrapper.dartindex a72f5dc7ce..5824ab8aa9 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/swipe_selection_wrapper.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/swipe_selection_wrapper.dart@@ -39,11 +39,14 @@ class _SwipeSelectionWrapperState extends State<SwipeSelectionWrapper> {double _currentPointerY = 0;// Auto-scroll constants- static const double _baseScrollSpeed = 2.0; // Base speed in pixels per frame- static const double _maxScrollSpeed = 15.0; // Maximum speed cap+ static const double _maxScrollSpeed = 30.0; // Maximum speed capstatic const double _scrollIntervalMs = 8.33; // ~120fps in millisecondsstatic const double _exponentialFactor =0.015; // Controls speed increase rate+ static const double _referenceMaxDistance = 200.0; // Distance for max speed+ // Pre-calculated denominator for speed formula: e^(factor * maxDist) - 1+ static final double _speedDenominator =+ math.exp(_exponentialFactor * _referenceMaxDistance) - 1;@overrideWidget build(BuildContext context) {@@ -128,9 +131,16 @@ class _SwipeSelectionWrapperState extends State<SwipeSelectionWrapper> {/// Calculate exponential scroll speed based on distance from boundarydouble _calculateScrollSpeed(double distanceFromBoundary) {- // Exponential formula: speed = base * e^(factor * distance)- final speed =- _baseScrollSpeed * math.exp(_exponentialFactor * distanceFromBoundary);+ // Modified exponential formula that starts at 0 and grows to max speed+ // speed = maxSpeed * (e^(factor * distance) - 1) / (e^(factor * maxDist) - 1)+ // This ensures speed starts at 0 when distance is 0++ if (distanceFromBoundary <= 0) return 0;++ // Calculate speed using pre-calculated denominator+ final numerator = math.exp(_exponentialFactor * distanceFromBoundary) - 1;+ final speed = _maxScrollSpeed * (numerator / _speedDenominator);+return math.min(speed, _maxScrollSpeed);}