play currently focused video in tiktok mode

This commit is contained in:
Simon
2026-06-18 13:42:51 +00:00
parent 988e11b159
commit 6b36b97bd1
2 changed files with 41 additions and 5 deletions

View File

@@ -211,7 +211,7 @@ App.feed = App.feed || {};
if (scroller) scroller.scrollTop = 0;
};
App.feed.open = function() {
App.feed.open = function(startVideoId) {
const container = document.getElementById('feed-view');
const scroller = getScroller();
if (!container || !scroller) return;
@@ -247,14 +247,21 @@ App.feed = App.feed || {};
if (sentinel) sentinelObserver.observe(sentinel);
}
App.feed.renderSlides();
document.querySelectorAll('.feed-slide').forEach((slide) => observer.observe(slide));
container.classList.add('open');
container.setAttribute('aria-hidden', 'false');
document.body.classList.add('feed-mode-open');
document.body.style.overflow = 'hidden';
App.feed.renderSlides();
if (startVideoId != null) {
const targetSlide = Array.from(scroller.querySelectorAll('.feed-slide'))
.find((slide) => slide.dataset.videoId === String(startVideoId));
if (targetSlide) scroller.scrollTop = targetSlide.offsetTop;
}
document.querySelectorAll('.feed-slide').forEach((slide) => observer.observe(slide));
App.feed.updateToggleButton();
App.feed.updateMuteButton();
};
@@ -276,7 +283,10 @@ App.feed = App.feed || {};
if (state.feedOpen) {
App.feed.close();
} else {
App.feed.open();
const focusedId = App.videos && typeof App.videos.getFocusedVideoId === 'function'
? App.videos.getFocusedVideoId()
: null;
App.feed.open(focusedId);
}
};