dhammawatthumpra commited on
Commit
0328af1
·
1 Parent(s): 634c146

fix: reset reader scroll position to top when new page loads

Browse files
webapp/tipitaka-web/src/components/layout/ReaderPanel.tsx CHANGED
@@ -171,6 +171,16 @@ const ReaderPanel: React.FC = () => {
171
  .finally(() => setLoading(false));
172
  }, [currentVolume, currentPage]);
173
 
 
 
 
 
 
 
 
 
 
 
174
  const { reader: readerCls } = THEME_STYLES[theme] ?? THEME_STYLES.dark;
175
  const shellCls = SHELL_STYLES[theme] ?? SHELL_STYLES.dark;
176
 
 
171
  .finally(() => setLoading(false));
172
  }, [currentVolume, currentPage]);
173
 
174
+ // Reset scroll to top when new page content is rendered
175
+ useEffect(() => {
176
+ if (!loading && content) {
177
+ const container = document.getElementById('reader-scroll-container');
178
+ if (container) {
179
+ container.scrollTop = 0;
180
+ }
181
+ }
182
+ }, [loading, content]);
183
+
184
  const { reader: readerCls } = THEME_STYLES[theme] ?? THEME_STYLES.dark;
185
  const shellCls = SHELL_STYLES[theme] ?? SHELL_STYLES.dark;
186