Skip to content

Commit d7873a8

Browse files
authored
Ignore vertical swipes (#25)
1 parent d60d3cb commit d7873a8

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ All notable changes to this project will be documented in this file. Take a look
2222
#### Navigator
2323

2424
* `EpubNavigatorFragment`'s `goForward()` and `goBackward()` are now jumping to the previous or next pages instead of resources.
25+
* [#20](https://github.com/readium/kotlin-toolkit/issues/20) EPUB navigator stuck between two pages with vertical swipes
2526

2627

2728
## [2.1.0]

readium/navigator/src/main/java/org/readium/r2/navigator/R2WebView.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ class R2WebView(context: Context, attrs: AttributeSet) : R2BasicWebView(context,
122122
* Position of the last motion event.
123123
*/
124124
private var mLastMotionX: Float = 0.toFloat()
125-
private var mLastMotionY: Float = 0.toFloat()
126125
private var mInitialMotionX: Float = 0.toFloat()
127126
private var mInitialMotionY: Float = 0.toFloat()
128127

@@ -685,7 +684,6 @@ class R2WebView(context: Context, attrs: AttributeSet) : R2BasicWebView(context,
685684
mInitialMotionX = ev.x
686685
mLastMotionX = mInitialMotionX
687686
mInitialMotionY = ev.y
688-
mLastMotionY = mInitialMotionY
689687
mActivePointerId = ev.getPointerId(0)
690688
}
691689
MotionEvent.ACTION_MOVE -> {
@@ -700,18 +698,15 @@ class R2WebView(context: Context, attrs: AttributeSet) : R2BasicWebView(context,
700698
val pointerIndex = ev.findPointerIndex(mActivePointerId)
701699
val x = ev.getX(pointerIndex)
702700
val xDiff = abs(x - mLastMotionX)
703-
val y = ev.getY(pointerIndex)
704-
val yDiff = abs(y - mLastMotionY)
705-
if (DEBUG) Timber.v("Moved x to $x,$y diff=$xDiff,$yDiff")
701+
if (DEBUG) Timber.v("Moved x to $x diff=$xDiff")
706702

707-
if (xDiff > mTouchSlop && xDiff > yDiff) {
703+
if (xDiff > mTouchSlop) {
708704
if (DEBUG) Timber.v("Starting drag!")
709705
mIsBeingDragged = true
710706
mLastMotionX = if (x - mInitialMotionX > 0)
711707
mInitialMotionX + mTouchSlop
712708
else
713709
mInitialMotionX - mTouchSlop
714-
mLastMotionY = y
715710
setScrollState(SCROLL_STATE_DRAGGING)
716711
setScrollingCacheEnabled(true)
717712
}

0 commit comments

Comments
 (0)