diff --git a/lib/src/scroll_state.dart b/lib/src/scroll_state.dart index 4da8130..d15b880 100644 --- a/lib/src/scroll_state.dart +++ b/lib/src/scroll_state.dart @@ -14,7 +14,8 @@ class ScrollState with ChangeNotifier { ScrollState(this.mobilePhysics, this.durationMS); - void handleDesktopScroll(PointerSignalEvent event) { + void handleDesktopScroll( + PointerSignalEvent event, int scrollSpeed, Curve animationCurve) { // Ensure desktop physics is being used. if (physics == kMobilePhysics) { physics = kDesktopPhysics; @@ -32,12 +33,12 @@ class ScrollState with ChangeNotifier { if (dy > 0) return; } } - futurePosition += event.scrollDelta.dy; + futurePosition += event.scrollDelta.dy * scrollSpeed; controller.animateTo( futurePosition, duration: Duration(milliseconds: durationMS), - curve: Curves.linear, + curve: animationCurve, ); } } diff --git a/lib/src/source.dart b/lib/src/source.dart index e49b00e..d6440de 100644 --- a/lib/src/source.dart +++ b/lib/src/source.dart @@ -6,12 +6,16 @@ import 'scroll_state.dart'; class DynMouseScroll extends StatelessWidget { final ScrollPhysics mobilePhysics; final int durationMS; + final int scrollSpeed; + final Curve animationCurve; final Function(BuildContext, ScrollController, ScrollPhysics) builder; const DynMouseScroll({ super.key, this.mobilePhysics = kMobilePhysics, this.durationMS = 200, + this.scrollSpeed = 1, + this.animationCurve = Curves.linear, required this.builder, }); @@ -24,7 +28,8 @@ class DynMouseScroll extends StatelessWidget { final controller = scrollState.controller; final physics = context.select((ScrollState s) => s.physics); return Listener( - onPointerSignal: scrollState.handleDesktopScroll, + onPointerSignal: (signalEvent) => scrollState.handleDesktopScroll( + signalEvent, scrollSpeed, animationCurve), onPointerDown: scrollState.handleTouchScroll, child: builder(context, controller, physics), ); diff --git a/pubspec.yaml b/pubspec.yaml index 112b6c5..2f255e1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: dyn_mouse_scroll description: A wrapper for scrollable widgets that enables smooth scrolling with a mouse on all platforms. -version: 1.0.7 +version: 1.0.8 repository: https://github.com/Bluebar1/dyn_mouse_scroll environment: