Riff / Built on the open web / Interface

scrollIntoView

Brings the playing track into view when Up next opens.

Now Playing with the Up next sheet open, listing the rest of the post's tracks
The playing track in the Up next list was scrolled into view when the sheet opened.

How Riff uses it

When the Up next sheet opens, the current track's item in the list is scrolled into view with block: nearest. In the Listen app, after a view swap, the app scrolls to its top only if it had scrolled off above the viewport.

Why

A long queue would otherwise open at its top with the playing track somewhere below.

Where

Links open the source at the commit this page was published from.

Reference: scrollIntoView on MDN.