From f6ac4c532b0284b731e661df9c297e1d240ab530 Mon Sep 17 00:00:00 2001 From: Manuinder Sekhon Date: Sat, 17 Feb 2024 04:13:13 +0530 Subject: [PATCH] feat: Calculate targetPixels for PageViewTypeScrollPhysics same as actual PageView physics --- lib/src/infinite_carousel.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/infinite_carousel.dart b/lib/src/infinite_carousel.dart index 3cd45d6..c8e683d 100644 --- a/lib/src/infinite_carousel.dart +++ b/lib/src/infinite_carousel.dart @@ -611,7 +611,7 @@ class PageViewTypeScrollPhysics extends ScrollPhysics { double _getTargetPixels( _InfiniteScrollPosition metrics, Tolerance tolerance, double velocity) { int item = metrics.itemIndex; - if (velocity * metrics.velocityFactor < -tolerance.velocity) { + if (velocity < -tolerance.velocity) { item -= 1; } else if (velocity > tolerance.velocity) { item += 1; @@ -639,7 +639,7 @@ class PageViewTypeScrollPhysics extends ScrollPhysics { spring, metrics.pixels, targetPixels, - velocity * metrics.velocityFactor, + velocity, tolerance: tolerance, ); }