Viewerframe Mode Refresh Top Official

function render() const html = state.items.map(item => <div class="item">$item</div> ).join(''); state.frameElement.innerHTML = html;

Advanced implementations use virtual scrolling (e.g., react-window or tanstack virtual ). Here, "refresh top" means resetting the virtual scroll index to 0 and discarding the cache. viewerframe mode refresh top

deliberately avoids this unpredictable reset. Instead, it declares a specific, predictable behavior: Every manual or timed refresh forces the frame to reset to the top. This sounds counterintuitive, but for certain use cases (e.g., news headlines, dashboard KPI cards, or image galleries), it is the cleanest UX pattern. Part 3: Core Architectural Patterns Implementing "viewerframe mode refresh top" requires a specific architecture. Below are the three primary patterns developers use. Pattern A: The Controlled Scroll Reset (Manual Mode) This is the purest form of the keyword. The viewerframe is explicitly in "top mode." function render() const html = state

document.getElementById('refreshBtn').addEventListener('click', refreshTop); Instead, it declares a specific, predictable behavior: Every

/* Ensure fresh renders start at top */ .viewerframe:mode-refresh scroll-behavior: auto; scroll-snap-type: none;

.viewerframe > :first-child margin-top: 0;

// 4. Force scroll to top state.frameElement.scrollTop = 0;