diff --git a/src/elements/emby-scrollbuttons/utils.ts b/src/elements/emby-scrollbuttons/utils.ts index 0d925957a6..adb4c41834 100644 --- a/src/elements/emby-scrollbuttons/utils.ts +++ b/src/elements/emby-scrollbuttons/utils.ts @@ -76,7 +76,7 @@ function scrollToWindow({ let scrollToPosition: number; if (direction === ScrollDirection.RIGHT) { - const nextItem = items[lastVisibleIndex]; + const nextItem = items[lastVisibleIndex] ? items[lastVisibleIndex] : items[lastVisibleIndex - 1]; // This will be the position to anchor the item at `lastVisibleIndex` to the start of the view window. const nextItemScrollOffset = lastVisibleIndex * nextItem.offsetWidth;