Vixen
dd8b0a81
csharp
public sealed class ScrollView

A window onto content that is bigger than it is.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Scrolling is an offset, not a layout. ScrollTop writes OffsetY on the content, which is applied when absolute positions are accumulated — so a scroll costs one walk of the tree and no cascade, no flexbox and no measurement. A scroll view that moved its content by changing a layout property would relayout its entire subtree sixty times a second.

⚠ Everything stays in the tree, including what has scrolled out of sight. This is the plain scroll view; a list of a million rows wants VirtualizingPanel, which doc 09 makes a first-class primitive and which is owed. Said here rather than discovered: putting a hundred thousand elements in one of these will work and will not be fast.

The clipping is overflow: hidden in the theme rather than anything here, so it is the draw list's clip stack that does it — the same mechanism any other clipped element uses.

⚠ It reads no overflow of its own, including the per-axis pair, and that is a decision. In CSS overflow on a box is what conjures the scrollbars; here the bars are children this control creates and drives, and the property only says where the clip rectangle's edges are. Wiring the two together would mean this reading its own user-agent rule — scroll-view { overflow: hidden }, the one that makes it clip at all — as an instruction to hide both of its bars. Which bars a view offers is therefore a property of the control, and overflow-x on some other element is a clip and nothing more. The consequence is worth stating plainly: overflow-y: auto on a plain div cuts its content off and offers no way to reach it. Put a ScrollView there instead.

⚠ It does read four other families, and the distinction is the whole of doc 43 A18. scroll-margin-*, scroll-padding-*, scroll-behavior and overscroll-behavior* say nothing about whether this is a scroll container — which is what overflow would be claiming, and what the paragraph above refuses. They say where a scroll lands, how it gets there, and what happens at the end, which are questions only something that already scrolls can be asked. That is why the utilities were deferred until this control could read them rather than registered as properties on a box: a scroll-mt-4 on a div inside nothing is still inert, and correctly so.

Fields and properties (29)

  • protected override string TagName

    The element name this type answers to when a caller does not choose one.

  • protected override bool AcceptsFocus

    Whether the focus can rest on this kind of control at all.

  • public UiElement Content

    Where the content goes.

  • protected override UiElement ContentHost
  • public ScrollBar VerticalBar

    The bar down the right.

  • public ScrollBar HorizontalBar

    The bar along the bottom.

  • public float ScrollTop
  • public float ScrollLeft
  • public bool DragToScroll
  • public float MaximumTop

    How far down it can go.

  • public float MaximumLeft

    How far across it can go.

  • public bool IsScrolling

    Whether a smooth scroll is still on its way somewhere.

  • public const float SmoothingConstant

    How long a smooth scroll takes to cover about two thirds of the distance.

  • public const float FlingDecayConstant

    How long a fling takes to lose about two thirds of its speed.

  • public const float FlingStopSpeed

    How slow a fling has to get before it is over, in pixels per second.

  • public const float VelocityBlend

    How much of a new velocity reading is believed, against what was already known.

  • public bool IsFlinging

    Whether a fling is still carrying the content.

  • public const float RubberBandConstant

    How hard the edge resists, as a fraction of the first pixel that is given away.

  • public const float RubberBandSpringConstant

    How long the spring takes to give back about two thirds of the stretch.

  • public float OverscrollTop

    How far past its vertical end the content is being held, in pixels — negative above the start, positive below the end, zero for all but a handful of frames.

  • public float OverscrollLeft

    The same, horizontally.

  • public float PullToRefreshDistance

    How far the content must be pulled below its top before a release asks for a refresh.

  • public bool IsRubberBanding

    Whether either axis is being held past its end, or springing back from having been.

  • public const float AnchorEpsilon

    How far an anchor has to have moved before the offset follows it, in pixels.

  • public const float SnapIdleSeconds

    How long the wheel has to be still before the scroll is deemed to have come to rest.

  • public const float SnapProximity

    How near a candidate has to be for proximity to snap to it, as a fraction of the viewport.

  • public static readonly UiPropertyKey ScrollTopProperty

    Identity for ScrollTop.

  • public static readonly UiPropertyKey ScrollLeftProperty

    Identity for ScrollLeft.

  • public static readonly UiPropertyKey DragToScrollProperty

    Identity for DragToScroll.

Events (2)

  • public Action<ScrollView>? Scrolled

    Raised when either offset changes.

  • public Action<ScrollView>? PulledToRefresh

    Raised when the content was pulled past its top and let go.

Methods (10)

  • protected override void OnCreated()

    Builds whatever this element is made of, once, as it joins a document.

  • protected override void OnRemoved()

    Called once, as the element leaves the document.

  • public void ScrollIntoView(UiElement element)

    Scrolls until an element inside is visible.

  • public void ScrollTo(float top, float left)

    Scrolls to an offset, the way scroll-behavior says to.

  • public void StopFling()

    Drops any fling in flight, leaving the offset where it got to.

  • public void Settle()

    Abandons any smooth scroll in flight, leaving the offset where it got to.

  • public void Refresh()

    Brings the bars up to date with the content's size.

  • public void ClearScrollTop()

    Unsets ScrollTop, so it takes its default or its ancestor's value again.

  • public void ClearScrollLeft()

    Unsets ScrollLeft, so it takes its default or its ancestor's value again.

  • public void ClearDragToScroll()

    Unsets DragToScroll, so it takes its default or its ancestor's value again.

Used by (54, showing 40)

  • ChatPanelMmo.Ui
  • GalleryHelloUi
  • VendorPanelMmo.Ui
  • EditorShellBenchmarksVixen.Benchmarks.Ui
  • AccessibilityTreeTestsVixen.Ui.Controls.Tests
  • AccessibleNameLocalisationTestsVixen.Ui.Controls.Tests
  • CodeEditorVixen.Ui.Controls.Advanced
  • CodeEditorTestsVixen.Ui.Controls.Advanced.Tests
  • ControlVisualTestsVixen.Ui.Controls.Tests
  • DataGridVixen.Ui.Controls.Advanced
  • DataGridTestsVixen.Ui.Controls.Advanced.Tests
  • EditorShellBudgetTestsVixen.Ui.Controls.Advanced.Tests
  • NavigationInteractionTestsVixen.Ui.Controls.Tests
  • ScrollAnchoringTestsVixen.Ui.Controls.Tests
  • ScrollMomentumTestsVixen.Ui.Controls.Tests
  • ScrollRubberBandTestsVixen.Ui.Controls.Tests
  • ScrollSnapTestsVixen.Ui.Controls.Tests
  • ScrollViewTestsVixen.Ui.Controls.Tests
  • StickyPositionTestsVixen.Ui.Controls.Tests
  • SurfaceTestsVixen.Ui.Controls.Tests
  • TextFieldTestsVixen.Ui.Controls.Tests
  • TreeViewVixen.Ui.Controls.Advanced
  • TreeViewTestsVixen.Ui.Controls.Advanced.Tests
  • UtilityConsumptionProbeVixen.Ui.Styling.Utilities.Tests
  • VariableHeightVirtualisationTestsVixen.Ui.Controls.Tests
  • VirtualListReachTestsVixen.Ui.Controls.Tests
  • VirtualListSheetVixen.Ui.Controls.Tests
  • VirtualizingGridVixen.Ui.Controls
  • VirtualizingGridTestsVixen.Ui.Controls.Tests
  • VirtualizingPanelVixen.Ui.Controls
  • VirtualizingPanelTestsVixen.Ui.Controls.Tests
  • AddComponentMenuVixen.Editor.App
  • AddComponentMenuDumpTestsVixen.Editor.App.Tests
  • AddComponentMenuTestsVixen.Editor.App.Tests
  • AssetGridVixen.Editor.App
  • ConsoleViewVixen.Editor.Ui
  • ConsoleViewTestsVixen.Editor.Ui.Tests
  • EditorApplicationVixen.Editor.App
  • EditorSessionVixen.Editor.Testing
  • ImportSettingsViewVixen.Editor.AssetEditors