@@ -415,12 +415,20 @@ class PDFView(context: Context?, attrs: AttributeSet?) : RelativeLayout(context,
415415 when {
416416 isSwipeVertical -> when {
417417 withAnimation -> pdfAnimator.animateVertical(currentYOffset, offset)
418- else -> moveTo(currentXOffset, offset)
418+ else -> {
419+ moveTo(currentXOffset, offset)
420+ // Perform page snap after jumpTo completes to center the page
421+ if (isPageSnap) performPageSnap()
422+ }
419423 }
420424
421425 else -> when {
422426 withAnimation -> pdfAnimator.animateHorizontal(currentXOffset, offset)
423- else -> moveTo(offset, currentYOffset)
427+ else -> {
428+ moveTo(offset, currentYOffset)
429+ // Perform page snap after jumpTo completes to center the page
430+ if (isPageSnap) performPageSnap()
431+ }
424432 }
425433 }
426434 showPage(userPage)
@@ -1002,14 +1010,14 @@ class PDFView(context: Context?, attrs: AttributeSet?) : RelativeLayout(context,
10021010 }
10031011
10041012 postDelayed({
1005- if (! isRecycled && ! isRecycling && _pdfFile != null )
1006- jumpTo(
1007- page = when {
1008- currentPage > 0 -> currentPage
1009- else -> defaultPage
1010- },
1011- withAnimation = false
1012- )
1013+ if (! isRecycled && ! isRecycling && _pdfFile != null ) {
1014+ val targetPage = when {
1015+ currentPage > 0 -> currentPage
1016+ else -> defaultPage
1017+ }
1018+ logWriter?.writeLog( " Performing initial jump to page $targetPage " , " PDFView " )
1019+ jumpTo(page = targetPage, withAnimation = false )
1020+ }
10131021 }, initDelay)
10141022 } catch (e: Exception ) {
10151023 loadError(e)
@@ -1234,6 +1242,10 @@ class PDFView(context: Context?, attrs: AttributeSet?) : RelativeLayout(context,
12341242 internal fun updateScrollUIElements () {
12351243 if (isRecycled || isRecycling) return
12361244
1245+ // Don't report intermediate page numbers during page snap animations
1246+ // to avoid confusing callbacks with pages "in between" the target pages
1247+ if (isPageSnap && pdfAnimator.isFlinging) return
1248+
12371249 when {
12381250 ! documentFitsView() -> {
12391251 val positionOffset = positionOffset
0 commit comments