Scroll to correct position on action up or cancel

Since the scroll is being queued on the main executor, use an absolute
position instead of relative position. The scroll position might have
changed by the time the task runs.

Fixes: 164934224
Test: manual - repro steps
Change-Id: Ie1b14743479f81df03030c525e6aebc6a7f8df97
This commit is contained in:
Robert Snoeberger
2020-10-02 16:39:47 -04:00
parent e23fca65cd
commit 2b5655e858

View File

@@ -282,10 +282,12 @@ class MediaCarouselScrollHandler(
scrollXAmount = -1 * relativePos
}
if (scrollXAmount != 0) {
val dx = if (isRtl) -scrollXAmount else scrollXAmount
val newScrollX = scrollView.relativeScrollX + dx
// Delay the scrolling since scrollView calls springback which cancels
// the animation again..
mainExecutor.execute {
scrollView.smoothScrollBy(if (isRtl) -scrollXAmount else scrollXAmount, 0)
scrollView.smoothScrollTo(newScrollX, scrollView.scrollY)
}
}
val currentTranslation = scrollView.getContentTranslation()
@@ -553,4 +555,4 @@ class MediaCarouselScrollHandler(
}
}
}
}
}