@@ -5,7 +5,7 @@ All notable changes to AndroidPDFPreview will be documented in this file.
55The format is based on [ Keep a Changelog] ( https://keepachangelog.com/en/1.0.0/ ) ,
66and this project adheres to [ Semantic Versioning] ( https://semver.org/spec/v2.0.0.html ) .
77
8- ## [ 1.2.4] - 2025-10-28 - Critical Bug Fix: Page Calculation Accuracy with Page Snap
8+ ## [ 1.2.4] - 2025-10-29 - Critical Bug Fix: Page Navigation Callbacks & Page Snap Accuracy
99
1010### Fixed
1111
@@ -21,6 +21,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121 - Consistent page detection across scroll gestures, animations, and callbacks
2222 - Improved reliability with ` pageSnap=true ` configuration
2323
24+ - ** 🔄 Page Change Callback Reliability**
25+ - Fixed ` onPageChanged() ` callback not firing after scroll/animation completion
26+ - Added ` loadPageByOffset() ` calls in animation completion handlers (` handleAnimationEnd() ` and ` performFling() ` )
27+ - Ensures page change detection occurs after all navigation operations settle
28+ - ` onPageChanged() ` now fires reliably for manual scroll, fling, and programmatic navigation
29+
30+ - ** ⚡ Intermediate Callback Prevention**
31+ - Prevented ` onPageScrolled() ` from reporting intermediate page numbers during page snap animations
32+ - Added animation state check in ` updateScrollUIElements() ` to skip callbacks during active animations
33+ - Eliminates confusing page number reports during smooth page transitions
34+ - Cleaner callback sequence with only final page positions reported
35+
36+ - ** 🎯 JumpTo Page Snapping**
37+ - Added page snapping to non-animated ` jumpTo() ` calls when ` pageSnap=true ` is enabled
38+ - Ensures pages are properly centered after programmatic navigation
39+ - Consistent behavior between animated and non-animated page jumps
40+ - Fixed initial load page positioning issues
41+
2442### Technical Details
2543
2644- ** Page Calculation Algorithm Fix** :
@@ -29,14 +47,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2947 - Matches the exact logic used in ` loadPageByOffset() ` for page change detection
3048 - Eliminates discrepancies between scroll callbacks and actual page changes
3149
50+ - ** Animation Completion Handling** :
51+ - ` PdfAnimator.handleAnimationEnd() ` now calls ` loadPageByOffset() ` to detect page changes
52+ - ` PdfAnimator.performFling() ` calls ` loadPageByOffset() ` when fling animations complete
53+ - Ensures ` onPageChanged() ` fires after all animation types (page snap, zoom, fling)
54+ - Proper callback sequencing: animation → page detection → callback firing
55+
3256- ** Page Snap Compatibility** :
3357 - Fixed callback accuracy when ` pageSnap=true ` is enabled
3458 - Page numbers remain stable during snap animations
3559 - No more incorrect page reporting during scroll deceleration
60+ - Animation state tracking prevents intermediate callback reports
3661
3762### Migration Guide
3863
39- No code changes required. This is an internal bug fix that improves callback accuracy.
64+ No code changes required. This is an internal bug fix that improves callback accuracy and reliability .
4065
4166** What's Fixed:**
4267
@@ -48,6 +73,12 @@ pdfView.configureView {
4873 override fun onPageScrolled (page : Int , positionOffset : Float ) {
4974 // ✅ NOW ACCURATE: No more jumping between wrong page numbers
5075 // ✅ STABLE: Consistent page numbers during snap animations
76+ // ✅ NO INTERMEDIATE: Only reports final page positions
77+ }
78+
79+ override fun onPageChanged (page : Int , pageCount : Int ) {
80+ // ✅ NOW FIRES: After scroll/animation completion on new pages
81+ // ✅ RELIABLE: Works for all navigation methods (scroll, fling, jumpTo)
5182 }
5283 })
5384}
@@ -57,7 +88,17 @@ pdfView.configureView {
5788
5889- ` positionOffset ` conversion (` docLen * positionOffset ` ) didn't account for viewport size
5990- Screen-center calculation (` -(offset - screenCenter) ` ) provides accurate page detection
60- - Inconsistent algorithms caused callback/page change detection mismatch
91+ - Animation completion didn't trigger page change detection
92+ - Page snap animations caused intermediate callback reports
93+ - Missing ` loadPageByOffset() ` calls in animation end handlers
94+
95+ ** Affected Components:**
96+
97+ - ` PDFView.updateScrollUIElements() ` - Fixed page calculation and animation state checks
98+ - ` PdfAnimator.handleAnimationEnd() ` - Added page change detection after animations
99+ - ` PdfAnimator.performFling() ` - Added page change detection after flings
100+ - ` PDFView.jumpTo() ` - Added page snapping for non-animated jumps
101+ - ` PDFView.loadComplete() ` - Enhanced initial load page positioning
61102
62103``` gradle
63104dependencies {
0 commit comments