-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestMoreDragSort.js
More file actions
88 lines (76 loc) · 2.19 KB
/
TestMoreDragSort.js
File metadata and controls
88 lines (76 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/**
* @file testMoreDragSort.js
* @description
* @author liushun
* @created 2025/12/24 15:49
* @lastModified 2025/12/24 15:49
*/
/**
* @file TestDrag.js
* @description
* @author liushun
* @created 2025/12/24 15:17
* @lastModified 2025/12/24 15:17
*/
import {Dimensions, ScrollView, Text, View} from "react-native";
import DragSortView from "./lib/DragSortView";
import React, {useRef} from "react";
const windowWidth = Dimensions.get("window").width;
const TestMoreDragSort = () => {
const scrollViewRef = useRef(null); //最外层 scrollView
const scrollYRef = useRef(0); //已经滚动的距离
const scrollViewHeightRef = useRef(0); //页面展示视图大小
const renderOneItem = (item, index) => {
return(
<View style={{width: windowWidth, height: 50, backgroundColor: 'red', justifyContent: 'center', alignItems: 'center'}}>
<Text>{item}</Text>
</View>
)
}
const renderTwoItem = (item, index) => {
return(
<View style={{width: (windowWidth - 10)/2, height: 50, backgroundColor: 'blue', justifyContent: 'center', alignItems: 'center'}}>
<Text>{item}</Text>
</View>
)
}
return(
<View onLayout={(e)=>{
scrollViewHeightRef.current = e.nativeEvent.layout.height;
}}>
<ScrollView
bounces={false}
scrollEventThrottle={16}
ref={scrollViewRef}
onScroll={(e)=>{
scrollYRef.current = e.nativeEvent.contentOffset.y;
}}
>
<DragSortView
scrollYRef={scrollYRef}
scrollViewRef={scrollViewRef}
scrollViewHeightRef={scrollViewHeightRef}
column={1}
childrenWidth={windowWidth}
childrenHeight={50}
renderItem={renderOneItem}
rowSpace={10}
dataSource={['1','2','3','4','5','6','7','8','9','10','11','12', '13','14','15','16','17','18']}
/>
<DragSortView
scrollYRef={scrollYRef}
scrollViewRef={scrollViewRef}
scrollViewHeightRef={scrollViewHeightRef}
column={2}
childrenWidth={(windowWidth - 10)/2}
childrenHeight={50}
renderItem={renderTwoItem}
rowSpace={10}
columnSpace={10}
dataSource={['1','2','3','4','5','6','7','8','9','10','11','12', '13','14','15','16','17','18']}
/>
</ScrollView>
</View>
)
}
export default TestMoreDragSort;