MiuixExitUntilCollapsedScrollBehavior class
"折叠到顶部为止"的滚动行为。对应 Kotlin ExitUntilCollapsedScrollBehavior。
折叠量 MiuixTopAppBarState.heightOffset 直接锚定到内容滚动位置:
heightOffset = -(pixels - minScrollExtent),再由 setter 钳到 limit, 0。
只有内容滚回顶部对应位置,大标题才逐像素恢复;中途上/下滑不跳变。
松手吸附(snapOnRelease,对应原版 settleAppBar 的 snap 段):手指抬起
时若停在折叠过渡区中段,把列表本身动画到全展开/全折叠的对应滚动
位置。注意与早期(1.0.2–1.0.8)实现的关键区别:吸附动画的是 pixels 而非
heightOffset,折叠量始终是滚动位置的纯函数,不会重新引入"吸附后 offset 与
pixels 解耦、中部微下滑弹回大标题"的回归问题。
短页面(可滚行程不足以靠滚动位置把标题保持在折叠态)走专用路径:回弹 期间冻结折叠量,松手后按 MiuixTopAppBarDefaults.titleCoverHandoff 吸附到 近端,避免橡皮筋回弹把折叠中的标题拉回展开("回弹 + 闪烁")。
用法:
final behavior = miuixScrollBehavior();
MiuixScrollBehaviorListener(
behavior: behavior,
child: ListView(...),
);
MiuixTopAppBar(title: 'Title', scrollBehavior: behavior);
- Implemented types
Constructors
- MiuixExitUntilCollapsedScrollBehavior({MiuixTopAppBarState? state, bool canScroll()?, bool snapOnRelease = true, Duration snapDuration = const Duration(milliseconds: 280), Curve snapCurve = Curves.easeOutCubic, bool lockSmallTitleUntilTop = false})
Properties
- canScroll → bool Function()?
-
是否处理滚动事件。
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isPinned → bool
-
是否固定(不随滚动收起)。
no setteroverride
- isSnapInProgress → bool
-
吸附动画运行中。监听者可据此避免在吸附期间切换视觉状态造成闪烁。
no setter
- lockSmallTitleUntilTop → bool
-
可选增强(非原版行为,默认关闭):标题折叠后保持小标题,直到用户发起
新手势把内容拉回顶部才重新展开;惯性滚动碰巧到达顶部不触发展开,
避免阅读中标题在大/小态之间意外来回切换。
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- snapCurve → Curve
-
final
- snapDuration → Duration
-
吸附动画时长与曲线(对应原版
snapAnimationSpec)。final - snapOnRelease → bool
-
松手时若停在折叠过渡区中段,把列表吸附到全展开/全折叠的近端。
final
- state → MiuixTopAppBarState
-
final
Methods
-
handleScroll(
ScrollNotification n) → bool -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited