Class ActivityLogScrollFollowRule
When a scrolling activity log keeps its newest line in view. The log follows its newest line until the author scrolls up to read an earlier one, and follows again once they scroll back to the bottom, so a long run's last messages never sit below the fold while an author reading back is never yanked to the end.
Inherited Members
Namespace: Serenity.Shared.Layout
Assembly: Serenity.Shared.dll
Syntax
public static class ActivityLogScrollFollowRule
Remarks
Engine-agnostic: offsets and heights are the scroll view's own units. The drawing side asks for OffsetToRequest(bool, float, float) before it draws the scroll view, then passes what the scroll view answered to FollowsNewestLineAfterDraw(bool, float, float, float). While following, the offset requested is the measured bottom and never a value past the end: a scroll view adds a mouse-wheel step to the offset it was handed before clamping, so a request past the end would absorb the step, land back on the bottom, and read as still following. The bottom is measured when the log is drawn, so the pass that measures a taller log still draws it at the old bottom; NeedsAnotherPassToShowNewestLine(bool, float, float) tells the drawing side to draw once more.
Fields
BottomTolerance
How far above the bottom still counts as showing the newest line — well under one line.
Declaration
public const float BottomTolerance = 1
Field Value
| Type | Description |
|---|---|
| float |
Methods
BottomOffset(float, float)
The largest offset the scroll view allows: where the newest line is in view.
Declaration
public static float BottomOffset(float contentHeight, float viewportHeight)
Parameters
| Type | Name | Description |
|---|---|---|
| float | contentHeight | The height of everything the log holds. |
| float | viewportHeight | The height of the visible part of the log. |
Returns
| Type | Description |
|---|---|
| float | Zero when everything fits. |
FollowsNewestLineAfterDraw(bool, float, float, float)
Whether the log follows its newest line after the scroll view answered.
Declaration
public static bool FollowsNewestLineAfterDraw(bool followedBefore, float requestedOffset, float returnedOffset, float bottomOffset)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | followedBefore | Whether it followed before this draw. |
| float | requestedOffset | The offset handed to the scroll view (OffsetToRequest(bool, float, float)). |
| float | returnedOffset | The offset the scroll view answered. |
| float | bottomOffset | The scroll view's bottom, from the last time it was measured. |
Returns
| Type | Description |
|---|---|
| bool | Unchanged when the scroll view answered exactly what it was asked — nothing moved it. Otherwise the author (or the view clamping a stale bottom to a shorter log's end) moved it, and it follows exactly when the answer shows the newest line. |
IsAtNewestLine(float, float)
True when offset shows the newest line.
Declaration
public static bool IsAtNewestLine(float offset, float bottomOffset)
Parameters
| Type | Name | Description |
|---|---|---|
| float | offset | The scroll view's offset. |
| float | bottomOffset | The scroll view's bottom, from BottomOffset(float, float). |
Returns
| Type | Description |
|---|---|
| bool | Whether the newest line is in view. |
NeedsAnotherPassToShowNewestLine(bool, float, float)
Whether the scroll view must be drawn once more before it shows the newest line: it follows, but the pass that just measured its bottom drew it above that bottom — a new line made the log taller.
Declaration
public static bool NeedsAnotherPassToShowNewestLine(bool followsNewestLine, float shownOffset, float bottomOffset)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | followsNewestLine | Whether the log follows its newest line after this draw. |
| float | shownOffset | The offset the scroll view was drawn at. |
| float | bottomOffset | The scroll view's bottom, measured on this draw. |
Returns
| Type | Description |
|---|---|
| bool | False for an author reading an earlier line, who is never moved. |
OffsetToRequest(bool, float, float)
The offset to hand the scroll view before drawing it.
Declaration
public static float OffsetToRequest(bool followsNewestLine, float currentOffset, float bottomOffset)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | followsNewestLine | Whether the log currently follows its newest line. |
| float | currentOffset | Where the author left the scroll view. |
| float | bottomOffset | The scroll view's bottom, from the last time it was measured. |
Returns
| Type | Description |
|---|---|
| float |
|