window.App = window.App || {}; App.feed = App.feed || {}; (function() { const state = App.state; // Tuning knobs for the virtualized feed. // // The feed is a y-scroll-snap list where every slide is exactly one // viewport tall. We never keep the whole list in the DOM. Instead we keep // a sliding window of slides around the active one: // // [active - HISTORY_COUNT .. active + RENDER_AHEAD] // // Everything outside that range is removed from the document; its video // JSON stays in state.loadedVideos so the slide is rebuilt instantly when // the user scrolls back to (or forward into) it. A top spacer absorbs the // height of the not-yet-rendered slides above the window, so adding or // removing slides never shifts the scroll position: any slide at index i // always sits at scrollTop === i * slideHeight regardless of the window. // // Separately we prefetch PREFETCH_PAGES worth of video JSON ahead of the // active slide so the data buffer is always full before we need to render // a slide from it. const PRELOAD_COUNT = 2; // slides ahead kept with a live