-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Single page scrolling #514
base: master
Are you sure you want to change the base?
Conversation
…ll snap current page to center. Zoom > min will use continuous scroll until zoom returns back to min, then it will snap to current page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added few notes to adjust your code with coding style used in this project
@@ -1,3 +1,4 @@ | |||
//apply plugin: 'java' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove comment
@@ -26,7 +27,7 @@ ext { | |||
|
|||
android { | |||
compileSdkVersion 25 | |||
buildToolsVersion '25.0.3' | |||
//buildToolsVersion '25.0.3' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove comment
@@ -171,6 +173,8 @@ public void onAnimationCancel(Animator animation) { | |||
|
|||
@Override | |||
public void onAnimationEnd(Animator animation) { | |||
if (pdfView.getPageViewType() == PageViewType.SINGLE && pdfView.getZoom() == pdfView.getMinZoom()) | |||
pdfView.jumpTo(pdfView.getCurrentPage(), true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add braces to if
block
@@ -178,6 +179,8 @@ public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float d | |||
} | |||
|
|||
private void onScrollEnd(MotionEvent event) { | |||
if (pdfView.getPageViewType() == PageViewType.SINGLE && !pdfView.isZooming()) | |||
pdfView.jumpTo(pdfView.getCurrentPage(), true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add braces to if
block
@@ -275,6 +279,8 @@ public void jumpTo(int page, boolean withAnimation) { | |||
|
|||
page = pdfFile.determineValidPageNumberFrom(page); | |||
float offset = -pdfFile.getPageOffset(page, zoom); | |||
if (getPageViewType() == PageViewType.SINGLE) | |||
offset = page == 0 ? 0 : -pdfFile.getPageOffset(page, zoom) + spacingPx; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add braces to if
block
@@ -13,11 +13,11 @@ repositories { | |||
} | |||
|
|||
apply plugin: 'com.android.application' | |||
apply plugin: 'android-apt' | |||
//apply plugin: 'android-apt' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove comment
|
||
android { | ||
compileSdkVersion 25 | ||
buildToolsVersion "25.0.3" | ||
//buildToolsVersion "25.0.3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove comment
@@ -102,7 +105,7 @@ void launchPicker() { | |||
|
|||
@AfterViews | |||
void afterViews() { | |||
pdfView.setBackgroundColor(Color.LTGRAY); | |||
pdfView.setBackgroundColor(Color.BLACK); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not modify sample when it isn't needed
.load(); | ||
.load();*/ | ||
|
||
PDFView.Configurator configurator = pdfView.fromAsset(SAMPLE_FILE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert it to chained style
@@ -114,7 +117,7 @@ void afterViews() { | |||
private void displayFromAsset(String assetFileName) { | |||
pdfFileName = assetFileName; | |||
|
|||
pdfView.fromAsset(SAMPLE_FILE) | |||
/*pdfView.fromAsset(SAMPLE_FILE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove comment
And of course thank you for contribution |
This doesn't work, I get blocked on the first page on portait. |
update for those who are struggling with a view page per page, just add to the constructor And you will get a page per page view, allowing you to swipe to the next page |
how can show curl or flip animation on page change or on page scroll ? |
how to solve this problem? please guide us with code snippet. |
Added "PageViewType" with two available values: SINGLE or CONTINUOUS. Continuous behaves as it did before. Single will swipe one page at a time, centered in the viewer. Zooming will behave like Continuous in order to view the whole page (so it won't keep snapping to leading edge of page), until zoomed to min where it will re-center.