scroll-behavior Smooth Duration Heuristic

Explicit caller smooth-scroll distance/speed/clamp heuristic, not CSS specification or browser smooth-scroll timing guarantee. Explicit supplied computed/layout context only; not a browser cascade/layout engine or cross-browser guarantee.

Description

A distance-based scrolling duration is an author-selected heuristic.

A distance-based scrolling duration is an author-selected heuristic.1

It does not reproduce a browser's native smooth-scrolling timing algorithm. Use scroll-behavior Smooth Duration Heuristic to evaluate the supplied inputs under the specific model below.

When to use scroll-behavior Smooth Duration Heuristic

Use scroll-behavior Smooth Duration Heuristic to evaluate the supplied inputs under the specific model below. Define the supplied layout, token or rendering scenario and establish the relevant units and browser context independently.

How to use scroll-behavior Smooth Duration Heuristic and understand its results

  1. Define the supplied layout, token or rendering scenario and establish the relevant units and browser context independently.
  2. Enter Observed distance px, Caller pixels per second, Caller min duration seconds, Caller max duration seconds using the field table and validation rules below, then run the tool.
  3. Read Caller heuristic duration seconds and interpret units, signs, ordering and placeholders as explained below.
  4. If the tool reports an input error, correct that field and rerun. A successful false result, empty match list or unknown-evidence placeholder has the specific meaning described here; check the limitations before applying the result.
Input fieldMeaningValue typeRequirement
observedDistancePxObserved distance pxnumberRequired; constraints below
callerPixelsPerSecondCaller pixels per secondnumberRequired; constraints below
callerMinDurationSecondsCaller min duration secondsnumberRequired; constraints below
callerMaxDurationSecondsCaller max duration secondsnumberRequired; constraints below

Enter nonnegative distance in px, positive speed in px/s and ordered nonnegative minimum and maximum durations in seconds. Divide distance by speed and clamp the result to those limits. This is a caller-defined heuristic, not the duration selected by a browser's smooth-scroll implementation.

durationSeconds = min(maximumSeconds,max(minimumSeconds,distancePx/speedPxPerSeconds))

Field order, units and branch conditions follow the implementation explanation above.

Output fieldMeaningValue type
callerHeuristicDurationSecondsCaller heuristic duration secondsnumber
json
{
  "input": {
    "observedDistancePx": 1000,
    "callerPixelsPerSecond": 2000,
    "callerMinDurationSeconds": 0.1,
    "callerMaxDurationSeconds": 1
  },
  "output": {
    "callerHeuristicDurationSeconds": 0.5
  }
}

Limitations and assumptions

It does not reproduce a browser's native smooth-scrolling timing algorithm. Apply the exact scope and assumptions described above.

All listed fields require explicit values. Unexpected fields, incorrect types, nonfinite numbers and sparse arrays fail validation. Domain-specific bounds, alignments and supported tokens are stated above; extremely large inputs or outputs can also be rejected. These errors differ from successful results such as false, no matches or unknown evidence.

Alternative or Complementary methods

Use scroll-snap-align Types Lookup for a related task: Scroll snapping aligns a snap area with a snapport along a chosen axis.

Use overscroll-behavior Scroll-Chaining Stop for a related task: Overscroll behavior concerns scroll chaining and boundary effects.

References

  1. scroll-behavior Smooth Duration Heuristic — tool.io

Similar or alternative tools

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