ENGLISH·COURSE API
    Preparing search index...
    • Returns the scroll offset that puts a row in the middle of a scrollable region, clamped to what the region can actually scroll.

      Parameters

      Returns number

      A scroll offset within [0, max(maxScrollTop, 0)]

      Clamping is the interesting half. A row in the first module cannot be centred — centring it would ask for a negative offset — and a row in the last module cannot either. In both cases the row lands off-centre but visible, which is the correct outcome: the region is already showing everything there is to show in that direction.

      A row taller than the region gets its own middle aligned with the region's middle, which puts its top edge above the fold. That is deliberate — with nothing else to go on, the middle of an oversized row is the best guess at what the reader wants to see.

      // A 40px row 1000px down a 600px-tall region that can scroll 2000px.
      centeredScrollTop({
      rowOffsetTop: 1000,
      rowHeight: 40,
      regionHeight: 600,
      maxScrollTop: 2000,
      }); // 720 — the row's middle now sits at the region's middle