diff --git a/src/components/Scrollpicker/index.tsx b/src/components/Scrollpicker/index.tsx index 650f778..e39807f 100644 --- a/src/components/Scrollpicker/index.tsx +++ b/src/components/Scrollpicker/index.tsx @@ -152,6 +152,10 @@ export class Scrollpicker extends React.Component{ + const targetItemIndex = this.scrollProper(scrollIndex, scrollHeight); + this.props.onChange && this.props.onChange(scrollIndex, targetItemIndex); - this.props.onChange && this.props.onChange(scrollIndex, targetItemIndex) + },100) } scrollProper (scrollIndex, scrollHeight, animated?) { @@ -354,9 +361,16 @@ export class Scrollpicker extends React.Component { - this.onScroll(scrollIndex, (e as any).nativeEvent.contentOffset.y) - }} + onScrollEndDrag: (e) => { + this.onScroll(scrollIndex, e.nativeEvent.contentOffset.y); + }, + onMomentumScrollBegin:()=>{ + this.timer && clearTimeout(this.timer); + this.timer = null + }, + onMomentumScrollEnd: (e) => { + this.onScroll(scrollIndex, e.nativeEvent.contentOffset.y); + } > {scrollItem.map((item, index) => { return (