Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.github.chrisbanes.photoview;

public @interface ParentScrollDirection {
int HORIZONTAL = 0;
int VERTICAL = 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,8 @@ public void setOnScaleChangeListener(OnScaleChangedListener onScaleChangedListen
public void setOnSingleFlingListener(OnSingleFlingListener onSingleFlingListener) {
attacher.setOnSingleFlingListener(onSingleFlingListener);
}

public void setParentScrollDirection(@ParentScrollDirection int scrollDirection) {
attacher.setParentScrollDirection(scrollDirection);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public class PhotoViewAttacher implements View.OnTouchListener,
private FlingRunnable mCurrentFlingRunnable;
private int mHorizontalScrollEdge = HORIZONTAL_EDGE_BOTH;
private int mVerticalScrollEdge = VERTICAL_EDGE_BOTH;
private int mParentScrollDirection = ParentScrollDirection.HORIZONTAL;
private float mBaseRotation;

private boolean mZoomEnabled = true;
Expand Down Expand Up @@ -118,9 +119,10 @@ public void onDrag(float dx, float dy) {
*/
ViewParent parent = mImageView.getParent();
if (mAllowParentInterceptOnEdge && !mScaleDragDetector.isScaling() && !mBlockParentIntercept) {
if (mHorizontalScrollEdge == HORIZONTAL_EDGE_BOTH
if ((mHorizontalScrollEdge == HORIZONTAL_EDGE_BOTH && mParentScrollDirection == ParentScrollDirection.HORIZONTAL)
|| (mHorizontalScrollEdge == HORIZONTAL_EDGE_LEFT && dx >= 1f)
|| (mHorizontalScrollEdge == HORIZONTAL_EDGE_RIGHT && dx <= -1f)
|| (mVerticalScrollEdge == VERTICAL_EDGE_BOTH && mParentScrollDirection == ParentScrollDirection.VERTICAL)
|| (mVerticalScrollEdge == VERTICAL_EDGE_TOP && dy >= 1f)
|| (mVerticalScrollEdge == VERTICAL_EDGE_BOTTOM && dy <= -1f)) {
if (parent != null) {
Expand Down Expand Up @@ -260,6 +262,10 @@ public void setOnSingleFlingListener(OnSingleFlingListener onSingleFlingListener
this.mSingleFlingListener = onSingleFlingListener;
}

public void setParentScrollDirection(@ParentScrollDirection int scrollDirection) {
this.mParentScrollDirection = scrollDirection;
}

@Deprecated
public boolean isZoomEnabled() {
return mZoomEnabled;
Expand Down