mirror of
https://github.com/dergigi/boris.git
synced 2025-12-19 23:54:23 +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) {
|
if (savedPosition && savedPosition.position > 0.05 && savedPosition.position < 1) {
|
||||||
console.log('🎯 [ContentPanel] Restoring position:', Math.round(savedPosition.position * 100) + '%')
|
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
|
// Wait for content to be fully rendered before scrolling
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const documentHeight = document.documentElement.scrollHeight
|
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)
|
console.log('✅ [ContentPanel] Restored to position:', Math.round(savedPosition.position * 100) + '%', 'scrollTop:', scrollTop)
|
||||||
}, 500) // Give content time to render
|
}, 500) // Give content time to render
|
||||||
|
} else {
|
||||||
|
console.log('⏭️ [ContentPanel] Auto-scroll disabled in settings')
|
||||||
|
}
|
||||||
} else if (savedPosition) {
|
} else if (savedPosition) {
|
||||||
if (savedPosition.position === 1) {
|
if (savedPosition.position === 1) {
|
||||||
console.log('✅ [ContentPanel] Article completed (100%), starting from top')
|
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>
|
<span>Sync reading position across devices</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ export interface UserSettings {
|
|||||||
paragraphAlignment?: 'left' | 'justify' // default: justify
|
paragraphAlignment?: 'left' | 'justify' // default: justify
|
||||||
// Reading position sync
|
// Reading position sync
|
||||||
syncReadingPosition?: boolean // default: false (opt-in)
|
syncReadingPosition?: boolean // default: false (opt-in)
|
||||||
|
autoScrollToPosition?: boolean // default: true (auto-scroll to last reading position)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loadSettings(
|
export async function loadSettings(
|
||||||
|
|||||||
Reference in New Issue
Block a user