mirror of
https://github.com/dergigi/boris.git
synced 2025-12-22 00:54:21 +01:00
fix: improve reading position calculation to reach 100%
- Add 5px threshold to detect when scrolled to bottom - Set position to exactly 1.0 (100%) when within 5px of bottom - Remove upper limit on saving positions (now saves 100% completion) - Always save when reaching 100% completion (important milestone) - Don't restore position for completed articles (100%), start from top - Better handling of edge cases in position detection - Matches ReadingProgressIndicator calculation logic
This commit is contained in:
@@ -224,7 +224,7 @@ const ContentPanel: React.FC<ContentPanelProps> = ({
|
||||
articleIdentifier
|
||||
)
|
||||
|
||||
if (savedPosition && savedPosition.position > 0.05 && savedPosition.position < 0.95) {
|
||||
if (savedPosition && savedPosition.position > 0.05 && savedPosition.position < 1) {
|
||||
console.log('🎯 [ContentPanel] Restoring position:', Math.round(savedPosition.position * 100) + '%')
|
||||
// Wait for content to be fully rendered before scrolling
|
||||
setTimeout(() => {
|
||||
@@ -240,7 +240,11 @@ 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 if (savedPosition) {
|
||||
console.log('⏭️ [ContentPanel] Position out of range (5-95%):', Math.round(savedPosition.position * 100) + '%')
|
||||
if (savedPosition.position === 1) {
|
||||
console.log('✅ [ContentPanel] Article completed (100%), starting from top')
|
||||
} else {
|
||||
console.log('⏭️ [ContentPanel] Position too early (<5%):', Math.round(savedPosition.position * 100) + '%')
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('❌ [ContentPanel] Failed to load reading position:', error)
|
||||
|
||||
Reference in New Issue
Block a user