Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bb61b2a

Browse files
committed
Merge branch 'hansinator85-master'
2 parents c591719 + 4db5703 commit bb61b2a

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class DragPinchManager implements GestureDetector.OnGestureListener, GestureDete
4343
private boolean swipeVertical;
4444

4545
private boolean scrolling = false;
46+
private boolean scaling = false;
4647

4748
public DragPinchManager(PDFView pdfView, AnimationManager animationManager) {
4849
this.pdfView = pdfView;
@@ -131,8 +132,9 @@ public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float d
131132
if (isZooming() || isSwipeEnabled) {
132133
pdfView.moveRelativeTo(-distanceX, -distanceY);
133134
}
134-
pdfView.loadPageByOffset();
135-
135+
if (!scaling || pdfView.doRenderDuringScale()) {
136+
pdfView.loadPageByOffset();
137+
}
136138
return true;
137139
}
138140

@@ -174,13 +176,15 @@ public boolean onScale(ScaleGestureDetector detector) {
174176

175177
@Override
176178
public boolean onScaleBegin(ScaleGestureDetector detector) {
179+
scaling = true;
177180
return true;
178181
}
179182

180183
@Override
181184
public void onScaleEnd(ScaleGestureDetector detector) {
182185
pdfView.loadPages();
183186
hideHandle();
187+
scaling = false;
184188
}
185189

186190
@Override

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,14 @@ ScrollHandle getScrollHandle() {
266266
*/
267267
private boolean annotationRendering = false;
268268

269+
/**
270+
* True if the view should render during scaling<br/>
271+
* Can not be forced on older API versions (< Build.VERSION_CODES.KITKAT) as the GestureDetector does
272+
* not detect scrolling while scaling.<br/>
273+
* False otherwise
274+
*/
275+
private boolean renderDuringScale = false;
276+
269277
/**
270278
* Construct the initial view
271279
*/
@@ -1104,6 +1112,14 @@ public boolean isAnnotationRendering() {
11041112
return annotationRendering;
11051113
}
11061114

1115+
public void enableRenderDuringScale(boolean renderDuringScale) {
1116+
this.renderDuringScale = renderDuringScale;
1117+
}
1118+
1119+
public boolean doRenderDuringScale() {
1120+
return renderDuringScale;
1121+
}
1122+
11071123
public PdfDocument.Meta getDocumentMeta() {
11081124
if (pdfDocument == null) {
11091125
return null;

0 commit comments

Comments
 (0)