react-native-drag-sort-list 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,8 +16,8 @@ import _ from "lodash";
16
16
  const TOP = 200; //上边距
17
17
  const BOTTOM = Dimensions.get('screen').height - 200; //下边距
18
18
 
19
- const TIME = Platform.OS === 'ios'?10:25; //每次滚动的时间间隔
20
- const DISTANCE = Platform.OS === 'ios'?2:4; //每次滚动的距离
19
+ const TIME = Platform.OS === 'ios'?10:10; //每次滚动的时间间隔
20
+ const DISTANCE = Platform.OS === 'ios'?5:5; //每次滚动的距离
21
21
 
22
22
  const MemoDragSortableView = (props, ref) => {
23
23
 
@@ -54,6 +54,8 @@ const MemoDragSortableView = (props, ref) => {
54
54
 
55
55
  const lastScrollYRef = useRef(0);
56
56
 
57
+ const needScrollYRef = useRef(0);
58
+
57
59
  //先构造拖拽所需数据, 由于改变位置是动画,所以不 setState 就可以改变位置
58
60
  useEffect(()=>{
59
61
 
@@ -101,7 +103,14 @@ const MemoDragSortableView = (props, ref) => {
101
103
  const startScroll = (distance) => {
102
104
  if(!scrollTimeRef.current){
103
105
  clearScrollInterval();
106
+ needScrollYRef.current = scrollYRef.current;
104
107
  scrollTimeRef.current = setInterval(() => {
108
+ console.log(needScrollYRef.current);
109
+ console.log("distance")
110
+ console.log(scrollYRef.current)
111
+ if(needScrollYRef.current - scrollYRef.current > 1){
112
+ return;
113
+ }
105
114
  //判断是否应该滚动,还是停止滚动
106
115
  if(Math.floor(scrollYRef?.current) <= Math.ceil(yRef.current + (parentYRef?parentYRef?.current:0)) && distance < 0){
107
116
  stopScroll();
@@ -113,8 +122,9 @@ const MemoDragSortableView = (props, ref) => {
113
122
  return;
114
123
  }
115
124
 
125
+ needScrollYRef.current = scrollYRef.current + distance;
116
126
  scrollViewRef?.current.scrollTo({
117
- y: scrollYRef?.current + distance,
127
+ y: needScrollYRef?.current,
118
128
  animated: false,
119
129
  })
120
130
  setDragOffSet(scrollYRef?.current - lastScrollYRef.current);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-drag-sort-list",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "A powerful React Native drag and sort component library with support for single and multi-column layouts",
5
5
  "main": "index.js",
6
6
  "scripts": {