diff --git a/package/lib/src/addon/modal.dart b/package/lib/src/addon/modal.dart index fe0a251..15da314 100644 --- a/package/lib/src/addon/modal.dart +++ b/package/lib/src/addon/modal.dart @@ -182,10 +182,10 @@ class _ModalExprollableState extends State { } } -/// Scroll physics commonly used for descendant scrollables of [ModalExprollable]. +/// Scroll physics normally used for descendant scrollables of [ModalExprollable]. /// -/// This physics always lets the user overscroll making *dra down to dismiss* action -/// is available on every platform. [ModalExprollable] provides this as the default physics +/// This physics always lets the user overscroll making *drag down to dismiss* action +/// available on every platform. [ModalExprollable] provides this as the default physics /// for its descendants via [ScrollConfiguration]. /// If you explicitly specify a physics for a descendant scrollable, /// consider to wrap that physics with this. @@ -196,11 +196,11 @@ class _ModalExprollableState extends State { /// ); /// ``` class ModalExprollableScrollPhysics extends ScrollPhysics { - /// Creates a scrolling physics that always lets the user overscroll. + /// Creates a scroll physics that always lets the user overscroll. /// - /// This will delegate its logic to [BouncingScrollPhysics] if the user overscrolls, - /// so that the *drag down to dismiss* action is available on every platform. - /// Otherwise, it delegates to the given [parent]. + /// This physics will delegate its logic to a [BouncingScrollPhysics] + /// while the user is overscrolling, so that the *drag down to dismiss* action is available + /// on every platform. Otherwise, it delegates to the given [parent]. const ModalExprollableScrollPhysics({ ScrollPhysics? parent, }) : super(parent: parent); diff --git a/package/lib/src/core/controller.dart b/package/lib/src/core/controller.dart index 234f8cb..680efc4 100644 --- a/package/lib/src/core/controller.dart +++ b/package/lib/src/core/controller.dart @@ -6,6 +6,7 @@ import 'package:exprollable_page_view/src/core/view.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/physics.dart'; import 'package:flutter/widgets.dart'; import 'package:meta/meta.dart'; @@ -125,10 +126,10 @@ class ExprollablePageController extends PageController { /// Crate a page controller with additional snap viewport offsets. /// - /// [additionalSnapOffsets] must not be empty. The viewport will snap to - /// the offsets given by [additionalSnapOffsets] in addition to + /// [additionalSnapOffsets] must not be empty. The viewport will snap to + /// the offsets given by [additionalSnapOffsets] in addition to /// [ViewportOffset.expanded] and [ViewportOffset.shrunk]. - /// + /// /// If [initialViewportOffset] or [maxViewportOffset] is not specified, /// the max offset in [additionalSnapOffsets] is used. factory ExprollablePageController.withAdditionalSnapOffsets( @@ -370,10 +371,14 @@ mixin PageViewportMetrics on ViewportMetrics { double get expandedOffset; /// Indicates if the viewport is fully shrunk. - bool get isShrunk => offset >= shrunkOffset; + bool get isShrunk => + nearEqual(offset, shrunkOffset, Tolerance.defaultTolerance.distance) || + offset > shrunkOffset; // Indicates if the viewport is fully expanded. - bool get isExpanded => offset <= expandedOffset; + bool get isExpanded => + nearEqual(offset, expandedOffset, Tolerance.defaultTolerance.distance) || + offset < expandedOffset; } /// A snapshot of the state of the conceptual viewport. diff --git a/package/lib/src/internal/scroll.dart b/package/lib/src/internal/scroll.dart index 8d83c41..d3783f8 100644 --- a/package/lib/src/internal/scroll.dart +++ b/package/lib/src/internal/scroll.dart @@ -191,13 +191,6 @@ class AbsorbScrollPosition extends ScrollPositionWithSingleContext { @override void absorb(ScrollPosition other) { super.absorb(other); - // if (other is AbsorbScrollPosition && other.absorber.pixels != null) { - // absorber.absorb(other.absorber.pixels!); - // } else if (hasPixels && hasContentDimensions) { - // // `super.absorb(other)` may set `super._pixels` to an invalid value, - // // which needs to be corrected. - // correctPixels(pixels); - // } if (other.hasPixels && other is AbsorbScrollPosition) { // `super.absorb(other)` may set `super._pixels` to an invalid value, // which needs to be corrected. @@ -354,7 +347,7 @@ class AbsorbScrollPosition extends ScrollPositionWithSingleContext { @override void jumpTo(double value) { goIdle(); - if (impliedPixels.almostEqualTo(value)) { + if (!impliedPixels.almostEqualTo(value)) { final double oldPixels = pixels; forcePixels(value); didStartScroll();