Scroll Position after Prepend
Preserve an existing scroll anchor after a known prepended extent, before any independently required scroll-range clamp.
Description
Preserve an existing scroll anchor after a known prepended extent, before any independently required scroll-range clamp.
Prepending content before the same visual anchor increases its offset by the prepended extent.
When to use this tool
Preserve an existing scroll anchor after a known prepended extent, before any independently required scroll-range clamp.
- Prepare the supplied scrollPosition, prependedExtent fields for this operation.
- Compare the complete example with the representation used by your own input before carrying the result into another step.
How to use the tool and how it works
- Enter scrollPosition, prependedExtent. Use the exact text syntax, units and index conventions explained below.
- Run the tool. If input validation fails, correct the supplied fields before interpreting any result.
- Read result.anchorPreservingPosition, result.assumption. Interpret false, null and empty lists using the distinctions below; they can be valid outputs.
Require nonnegative scrollPosition and prependedExtent. Return their sum as anchorPreservingPosition with the stated same-anchor/no-other-change assumption.1
| Input field | Meaning and representation | Accepted input |
|---|---|---|
| scrollPosition | scroll position. | Finite number; zero or greater |
| prependedExtent | prepended extent. | Finite number; zero or greater |
| Output field | Interpretation |
|---|---|
| result | Object containing the named outputs below. |
| result.anchorPreservingPosition | The anchor preserving position value under the stated formula or text convention. |
| result.assumption | The assumption value under the stated formula or text convention. |
{
"input": {
"scrollPosition": 20,
"prependedExtent": 5
},
"output": {
"result": {
"anchorPreservingPosition": 25,
"assumption": "same-anchor-and-no-other-layout-change"
}
}
} Limitations and assumptions
- No anchor is discovered and no scroll action occurs. Actual browser clamping and simultaneous layout changes require separate handling.
- Rectangle arrays use [x,y,width,height] with nonnegative extents. All dimensions must use the same coordinate frame and unit; values are supplied rather than measured from a page.
- Every declared top-level field is required and unexpected fields are rejected. Numeric inputs must be finite; ordinary text fields are bounded to 8,192 UTF-16 code units, with tighter operation-specific limits where stated.
- String lists have at most 128 entries of at most 128 code units; matrices have at most 128 rows and columns. Larger numeric lists and parsed JSON have separate bounded budgets. Nonfinite results and excessively large serialized outputs are rejected.
- Indexes are zero-based and spans have an exclusive end unless explicitly stated otherwise. A valid false, null or empty-list result is distinct from malformed input.
Alternative or Complementary methods
Measure the actual layout when browser behavior matters. The formulas use supplied coordinates and explicit simplifications; they do not account for every box, writing mode, clipping ancestor or simultaneous layout change.
References
Similar or alternative tools
- Scroll Position after Item Resize
Adjust scroll position only when a resized item is independently established before the anchor; retain signed extent change and do not infer overlapping-anchor behavior.
- Scroll Position from Progress
Invert normalized scroll progress into a position using explicit content/viewport extents.