Skip to content

Commit 5db661b

Browse files
authored
Cancel thumb view touches with ACTION_CANCEL (#23)
1 parent 50e9ca6 commit 5db661b

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

indicator-fast-scroll/src/main/java/com/reddit/indicatorfastscroll/FastScrollerView.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ class FastScrollerView @JvmOverloads constructor(
301301
override fun onTouchEvent(event: MotionEvent): Boolean {
302302
fun View.containsY(y: Int) = y in (top until bottom)
303303

304-
if (event.action == MotionEvent.ACTION_UP) {
304+
if (event.action in MOTIONEVENT_STOP_ACTIONS) {
305305
isPressed = false
306306
lastSelectedPosition = null
307307
onItemIndicatorTouched?.invoke(false)
@@ -347,6 +347,11 @@ class FastScrollerView @JvmOverloads constructor(
347347

348348
companion object {
349349

350+
private val MOTIONEVENT_STOP_ACTIONS = intArrayOf(
351+
MotionEvent.ACTION_UP,
352+
MotionEvent.ACTION_CANCEL
353+
)
354+
350355
private fun FastScrollerView.createAdapterDataObserver(): RecyclerView.AdapterDataObserver {
351356
return object : RecyclerView.AdapterDataObserver() {
352357
override fun onChanged() {

0 commit comments

Comments
 (0)