Commit f5fc32ff authored by Tom Robinson's avatar Tom Robinson Committed by Kate Lovett

Update docs for GrowthDirection and scrollOffset (#39286)

parent 6e555a9c
...@@ -12,6 +12,7 @@ import 'binding.dart'; ...@@ -12,6 +12,7 @@ import 'binding.dart';
import 'box.dart'; import 'box.dart';
import 'debug.dart'; import 'debug.dart';
import 'object.dart'; import 'object.dart';
import 'viewport.dart';
import 'viewport_offset.dart'; import 'viewport_offset.dart';
// CORE TYPES FOR SLIVERS // CORE TYPES FOR SLIVERS
...@@ -27,17 +28,16 @@ import 'viewport_offset.dart'; ...@@ -27,17 +28,16 @@ import 'viewport_offset.dart';
/// vertical alphabetical list that is going [AxisDirection.down] with a /// vertical alphabetical list that is going [AxisDirection.down] with a
/// [GrowthDirection.reverse] would have the Z at the top (at scroll offset /// [GrowthDirection.reverse] would have the Z at the top (at scroll offset
/// zero) and the A below it. /// zero) and the A below it.
///
/// The direction in which the scroll offset increases is given by
/// [applyGrowthDirectionToAxisDirection].
enum GrowthDirection { enum GrowthDirection {
/// This sliver's contents are ordered so that the first item is at the lowest /// This sliver's contents are ordered in the same direction as the
/// scroll offset, and later items are at greater scroll offsets. The /// [AxisDirection].
/// direction in which the scroll offset increases is given by the
/// [AxisDirection] of the sliver.
forward, forward,
/// This sliver's contents are ordered so that the last item is at the lowest /// This sliver's contents are ordered in the opposite direction of the
/// scroll offset, and earlier items are at greater scroll offsets. The /// [AxisDirection].
/// direction in which the scroll offset increases is given by the
/// [AxisDirection] of the sliver.
reverse, reverse,
} }
...@@ -165,12 +165,6 @@ class SliverConstraints extends Constraints { ...@@ -165,12 +165,6 @@ class SliverConstraints extends Constraints {
/// top, with the bottom of the A at scroll offset zero, and the top of the Z /// top, with the bottom of the A at scroll offset zero, and the top of the Z
/// at the highest scroll offset. /// at the highest scroll offset.
/// ///
/// On the other hand, if the [axisDirection] is [AxisDirection.up] but the
/// [growthDirection] is [GrowthDirection.reverse], then an alphabetical list
/// will have A at the top, then B, then C, and so forth, with Z at the
/// bottom, with the bottom of the Z at scroll offset zero, and the top of the
/// A at the highest scroll offset.
///
/// If a viewport has an overall [AxisDirection] of [AxisDirection.down], then /// If a viewport has an overall [AxisDirection] of [AxisDirection.down], then
/// slivers above the absolute zero offset will have an axis of /// slivers above the absolute zero offset will have an axis of
/// [AxisDirection.up] and a growth direction of [GrowthDirection.reverse], /// [AxisDirection.up] and a growth direction of [GrowthDirection.reverse],
...@@ -181,9 +175,8 @@ class SliverConstraints extends Constraints { ...@@ -181,9 +175,8 @@ class SliverConstraints extends Constraints {
/// well, with zero at the absolute zero point, and positive numbers going /// well, with zero at the absolute zero point, and positive numbers going
/// away from there.) /// away from there.)
/// ///
/// In general, lists grow only in the positive scroll offset direction, so /// Normally, the absolute zero offset is determined by the viewport's
/// the only growth direction that is commonly seen is /// [RenderViewport.center] and [RenderViewport.anchor] properties.
/// [GrowthDirection.forward].
final GrowthDirection growthDirection; final GrowthDirection growthDirection;
/// The direction in which the user is attempting to scroll, relative to the /// The direction in which the user is attempting to scroll, relative to the
...@@ -205,12 +198,13 @@ class SliverConstraints extends Constraints { ...@@ -205,12 +198,13 @@ class SliverConstraints extends Constraints {
final ScrollDirection userScrollDirection; final ScrollDirection userScrollDirection;
/// The scroll offset, in this sliver's coordinate system, that corresponds to /// The scroll offset, in this sliver's coordinate system, that corresponds to
/// the earliest visible part of this sliver in the [AxisDirection]. /// the earliest visible part of this sliver in the [AxisDirection] if
/// [growthDirection] is [GrowthDirection.forward] or in the opposite
/// [AxisDirection] direction if [growthDirection] is [GrowthDirection.reverse].
/// ///
/// For example, if [AxisDirection] is [AxisDirection.down], then this is the /// For example, if [AxisDirection] is [AxisDirection.down] and [growthDirection]
/// scroll offset at the top of the visible portion of the sliver or /// is [GrowthDirection.forward], then scroll offset is the amount the top of
/// equivalently the amount the top of the sliver has been scrolled past the /// the sliver has been scrolled past the top of the viewport.
/// top of the viewport.
/// ///
/// This value is typically used to compute whether this sliver should still /// This value is typically used to compute whether this sliver should still
/// protrude into the viewport via [SliverGeometry.paintExtent] and /// protrude into the viewport via [SliverGeometry.paintExtent] and
...@@ -218,8 +212,10 @@ class SliverConstraints extends Constraints { ...@@ -218,8 +212,10 @@ class SliverConstraints extends Constraints {
/// sliver is above the beginning of the viewport. /// sliver is above the beginning of the viewport.
/// ///
/// For slivers whose top is not past the top of the viewport, the /// For slivers whose top is not past the top of the viewport, the
/// [scrollOffset] is `0` when [AxisDirection] is [AxisDirection.down]. This /// [scrollOffset] is `0` when [AxisDirection] is [AxisDirection.down] and
/// includes all the slivers that are below the bottom of the viewport. /// [growthDirection] is [GrowthDirection.forward]. The set of slivers with
/// [scrollOffset] `0` includes all the slivers that are below the bottom of the
/// viewport.
/// ///
/// [SliverConstraints.remainingPaintExtent] is typically used to accomplish /// [SliverConstraints.remainingPaintExtent] is typically used to accomplish
/// the same goal of computing whether scrolled out slivers should still /// the same goal of computing whether scrolled out slivers should still
......
...@@ -1138,6 +1138,9 @@ class RenderViewport extends RenderViewportBase<SliverPhysicalContainerParentDat ...@@ -1138,6 +1138,9 @@ class RenderViewport extends RenderViewportBase<SliverPhysicalContainerParentDat
/// The first child in the [GrowthDirection.forward] growth direction. /// The first child in the [GrowthDirection.forward] growth direction.
/// ///
/// This child that will be at the position defined by [anchor] when the
/// [offset.pixels] is `0`.
///
/// Children after [center] will be placed in the [axisDirection] relative to /// Children after [center] will be placed in the [axisDirection] relative to
/// the [center]. Children before [center] will be placed in the opposite of /// the [center]. Children before [center] will be placed in the opposite of
/// the [axisDirection] relative to the [center]. /// the [axisDirection] relative to the [center].
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment