diff --git a/WheelView/src/main/java/com/github/gzuliyujiang/wheelview/widget/WheelView.java b/WheelView/src/main/java/com/github/gzuliyujiang/wheelview/widget/WheelView.java index 1b2c475..ab4adc7 100644 --- a/WheelView/src/main/java/com/github/gzuliyujiang/wheelview/widget/WheelView.java +++ b/WheelView/src/main/java/com/github/gzuliyujiang/wheelview/widget/WheelView.java @@ -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(); }