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.

Description

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.

Resizing an item before a fixed visual anchor can require compensating the scroll position by the size change.

When to use this tool

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.

  • Prepare the supplied scrollPosition, oldItemExtent, newItemExtent, itemBeforeAnchor 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

  1. Enter scrollPosition, oldItemExtent, newItemExtent, itemBeforeAnchor. Use the exact text syntax, units and index conventions explained below.
  2. Run the tool. If input validation fails, correct the supplied fields before interpreting any result.
  3. Read result.conditionalPosition, result.signedExtentChange. Interpret false, null and empty lists using the distinctions below; they can be valid outputs.

Require nonnegative scroll and extents. signedExtentChange is new minus old; conditionalPosition adds that change only when itemBeforeAnchor is true.1

Input fieldMeaning and representationAccepted input
scrollPositionscroll position.Finite number; zero or greater
oldItemExtentold item extent.Finite number; zero or greater
newItemExtentnew item extent.Finite number; zero or greater
itemBeforeAnchorExplicit choice for item before anchor; supply a boolean rather than a text label.true or false
Output fieldInterpretation
resultObject containing the named outputs below.
result.conditionalPositionThe conditional position value under the stated formula or text convention.
result.signedExtentChangeThe signed extent change value under the stated formula or text convention.
json
{
  "input": {
    "scrollPosition": 20,
    "oldItemExtent": 5,
    "newItemExtent": 8,
    "itemBeforeAnchor": true
  },
  "output": {
    "result": {
      "conditionalPosition": 23,
      "signedExtentChange": 3
    }
  }
}

Limitations and assumptions

  • The caller supplies the anchor relationship. A negative candidate is not clamped, and other layout changes or browser anchoring rules are not modeled.
  • 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

  1. Tool behavior and example: Scroll Position after Item Resize — tool.io

Similar or alternative tools

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies