Skip to content

Commit 3f2360d

Browse files
authored
Merge pull request #5 from muthuraj57/master
Provided option to perform page snap without animation
2 parents f322a80 + 1b5e635 commit 3f2360d

File tree

1 file changed

+15
-3
lines changed
  • android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer

1 file changed

+15
-3
lines changed

android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/PDFView.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -985,10 +985,14 @@ void loadPageByOffset() {
985985
}
986986
}
987987

988+
public void performPageSnap() {
989+
performPageSnap(true);
990+
}
991+
988992
/**
989993
* Animate to the nearest snapping position for the current SnapPolicy
990994
*/
991-
public void performPageSnap() {
995+
public void performPageSnap(boolean withAnimation) {
992996
if (!pageSnap || pdfFile == null || pdfFile.getPagesCount() == 0) {
993997
return;
994998
}
@@ -1000,9 +1004,17 @@ public void performPageSnap() {
10001004

10011005
float offset = snapOffsetForPage(centerPage, edge);
10021006
if (swipeVertical) {
1003-
animationManager.startYAnimation(currentYOffset, -offset);
1007+
if (withAnimation) {
1008+
animationManager.startYAnimation(currentYOffset, -offset);
1009+
} else {
1010+
moveTo(currentXOffset, -offset);
1011+
}
10041012
} else {
1005-
animationManager.startXAnimation(currentXOffset, -offset);
1013+
if (withAnimation) {
1014+
animationManager.startXAnimation(currentXOffset, -offset);
1015+
} else {
1016+
moveTo(-offset, currentYOffset);
1017+
}
10061018
}
10071019
}
10081020

0 commit comments

Comments
 (0)