Open cla99ic opened 2 years ago
Is there any update regarding this issue?
It seems to be related to this runnable in the Carousel class
Runnable mUpdateRunnable = new Runnable() {
@Override
public void run() {
mMotionLayout.setProgress(0);
updateItems();
mAdapter.onNewItem(mIndex);
float velocity = mMotionLayout.getVelocity();
if (mTouchUpMode == TOUCH_UP_CARRY_ON && velocity > mVelocityThreshold
&& mIndex < mAdapter.count() - 1) {
final float v = velocity * mDampening;
if (mIndex == 0 && mPreviousIndex > mIndex) {
// don't touch animate when reaching the first item
return;
}
if (mIndex == mAdapter.count() - 1 && mPreviousIndex < mIndex) {
// don't touch animate when reaching the last item
return;
}
mMotionLayout.post(new Runnable() {
@Override
public void run() {
mMotionLayout.touchAnimateTo(MotionLayout.TOUCH_UP_DECELERATE_AND_COMPLETE,
1, v);
}
});
}
}
};
Specifically this call to mMotionLayout.touchAnimateTo(MotionLayout.TOUCH_UP_DECELERATE_AND_COMPLETE, 1, v);
. Since velocity seems to be always positive even when swiping right or left, this piece of code will always move to the next view of the carousel. I've tried swapping the position value of the call from 1 to -1, but the result remains the same
On carousel demo, on right swiping, it goes a little back then it continues by going forward.