Skip to content

Commit

Permalink
新增功能 滚动到尽头就不可以再拖动
Browse files Browse the repository at this point in the history
  • Loading branch information
bitter committed Dec 1, 2023
1 parent 0a9c883 commit 28ccca0
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,24 @@ private void handleActionMove(MotionEvent event) {
if (Math.abs(move) < 1) {
return;
}
scrollOffsetYCoordinate += move;

// Scroll limit
float topLimit = (defaultItemPosition) * itemHeight;
float bottomLimit = -(getItemCount() - 1 - defaultItemPosition) * itemHeight;
boolean disableScrollTop = scrollOffsetYCoordinate >=topLimit && move > 0;
boolean disableScrollBottom = scrollOffsetYCoordinate <= bottomLimit && move < 0;
if(!cyclicEnabled)
{
if(!disableScrollBottom && !disableScrollTop)
{
scrollOffsetYCoordinate += move;
}
}else
{
scrollOffsetYCoordinate += move;
}
//

lastPointYCoordinate = (int) event.getY();
invalidate();
}
Expand Down

0 comments on commit 28ccca0

Please sign in to comment.