mirror of
https://github.com/dergigi/boris.git
synced 2025-12-19 15:44:20 +01:00
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:
@@ -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')
|
||||
|
||||
@@ -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>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user