the traditional scrollTo method is not reliable since offsetTop computation is complicated and usually wrong for modern complex layout structure.
use scrollIntoView instead.
However using scrollIntoView will not instantly scroll to the desired position. It is because scroll-behavior: smooth is set by default.
scroll-behavior: auto shall temporarily set by CSS. (avoid using scrollIntoViewOptions)
after the scrollTop is ready, allow the main window to call scrollLyrics. This is done by setTimeout delay
before that, the content will be still visible just autoscroll is not yet ready
the traditional
scrollTo
method is not reliable sinceoffsetTop
computation is complicated and usually wrong for modern complex layout structure.use
scrollIntoView
instead.However using
scrollIntoView
will not instantly scroll to the desired position. It is becausescroll-behavior: smooth
is set by default.scroll-behavior: auto
shall temporarily set by CSS. (avoid usingscrollIntoViewOptions
)after the
scrollTop
is ready, allow the main window to callscrollLyrics
. This is done bysetTimeout
delay before that, the content will be still visible just autoscroll is not yet ready