Skip to content

Commit

Permalink
Merge pull request #346 from k849717776/scroll-limit
Browse files Browse the repository at this point in the history
新增功能 滚动到尽头就不可以再拖动
  • Loading branch information
liyujiang-gzu authored Dec 2, 2023
2 parents 0a9c883 + 28ccca0 commit 51852c3
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 51852c3

Please sign in to comment.