MCPcopy Create free account
hub / github.com/astercloud/aster / saveScrollPositions

Function saveScrollPositions

ui/src/composables/useStreamingState.ts:107–130  ·  view source on GitHub ↗

* Save current scroll positions within the container

()

Source from the content-addressed store, hash-verified

105 * Save current scroll positions within the container
106 */
107 function saveScrollPositions(): void {
108 if (!preserveScroll || !containerRef.value) return;
109
110 const state = getPreservedState(surfaceId);
111 state.scrollPositions.clear();
112
113 // Save container scroll position
114 state.scrollPositions.set('__container__', {
115 top: containerRef.value.scrollTop,
116 left: containerRef.value.scrollLeft,
117 });
118
119 // Save scroll positions of scrollable children
120 const scrollableElements = containerRef.value.querySelectorAll('[data-scroll-preserve]');
121 scrollableElements.forEach((el) => {
122 const id = el.getAttribute('data-scroll-preserve') || el.id;
123 if (id) {
124 state.scrollPositions.set(id, {
125 top: (el as HTMLElement).scrollTop,
126 left: (el as HTMLElement).scrollLeft,
127 });
128 }
129 });
130 }
131
132 /**
133 * Restore saved scroll positions

Callers 1

saveStateFunction · 0.85

Calls 2

getPreservedStateFunction · 0.85
setMethod · 0.45

Tested by

no test coverage detected