Skip to content

Commit 51852c3

Browse files
Merge pull request #346 from k849717776/scroll-limit
新增功能 滚动到尽头就不可以再拖动
2 parents 0a9c883 + 28ccca0 commit 51852c3

File tree

1 file changed

+18
-1
lines changed
  • WheelView/src/main/java/com/github/gzuliyujiang/wheelview/widget

1 file changed

+18
-1
lines changed

WheelView/src/main/java/com/github/gzuliyujiang/wheelview/widget/WheelView.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,24 @@ private void handleActionMove(MotionEvent event) {
10801080
if (Math.abs(move) < 1) {
10811081
return;
10821082
}
1083-
scrollOffsetYCoordinate += move;
1083+
1084+
// Scroll limit
1085+
float topLimit = (defaultItemPosition) * itemHeight;
1086+
float bottomLimit = -(getItemCount() - 1 - defaultItemPosition) * itemHeight;
1087+
boolean disableScrollTop = scrollOffsetYCoordinate >=topLimit && move > 0;
1088+
boolean disableScrollBottom = scrollOffsetYCoordinate <= bottomLimit && move < 0;
1089+
if(!cyclicEnabled)
1090+
{
1091+
if(!disableScrollBottom && !disableScrollTop)
1092+
{
1093+
scrollOffsetYCoordinate += move;
1094+
}
1095+
}else
1096+
{
1097+
scrollOffsetYCoordinate += move;
1098+
}
1099+
//
1100+
10841101
lastPointYCoordinate = (int) event.getY();
10851102
invalidate();
10861103
}

0 commit comments

Comments
 (0)