feat: add auto-scroll to reading position setting

- Add autoScrollToPosition setting (default: true)
- Add checkbox in Layout & Behavior settings
- Only auto-scroll when setting is enabled
- Allows users to disable auto-scrolling while keeping sync enabled
This commit is contained in:
Gigi
2025-10-15 22:53:47 +02:00
parent 6758b9678b
commit 8800791723
3 changed files with 33 additions and 13 deletions

View File

@@ -226,6 +226,9 @@ const ContentPanel: React.FC<ContentPanelProps> = ({
if (savedPosition && savedPosition.position > 0.05 && savedPosition.position < 1) {
console.log('🎯 [ContentPanel] Restoring position:', Math.round(savedPosition.position * 100) + '%')
// Only auto-scroll if the setting is enabled (default: true)
if (settings?.autoScrollToPosition !== false) {
// Wait for content to be fully rendered before scrolling
setTimeout(() => {
const documentHeight = document.documentElement.scrollHeight
@@ -239,6 +242,9 @@ const ContentPanel: React.FC<ContentPanelProps> = ({
console.log('✅ [ContentPanel] Restored to position:', Math.round(savedPosition.position * 100) + '%', 'scrollTop:', scrollTop)
}, 500) // Give content time to render
} else {
console.log('⏭️ [ContentPanel] Auto-scroll disabled in settings')
}
} else if (savedPosition) {
if (savedPosition.position === 1) {
console.log('✅ [ContentPanel] Article completed (100%), starting from top')

View File

@@ -117,6 +117,19 @@ const LayoutBehaviorSettings: React.FC<LayoutBehaviorSettingsProps> = ({ setting
<span>Sync reading position across devices</span>
</label>
</div>
<div className="setting-group">
<label htmlFor="autoScrollToPosition" className="checkbox-label">
<input
id="autoScrollToPosition"
type="checkbox"
checked={settings.autoScrollToPosition !== false}
onChange={(e) => onUpdate({ autoScrollToPosition: e.target.checked })}
className="setting-checkbox"
/>
<span>Auto-scroll to last reading position</span>
</label>
</div>
</div>
)
}

View File

@@ -56,6 +56,7 @@ export interface UserSettings {
paragraphAlignment?: 'left' | 'justify' // default: justify
// Reading position sync
syncReadingPosition?: boolean // default: false (opt-in)
autoScrollToPosition?: boolean // default: true (auto-scroll to last reading position)
}
export async function loadSettings(