@lynx-example/lynx-ui-swiper 0.0.4 → 0.0.6
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.
- package/Basic/index.tsx +3 -3
- package/Basic/styles.css +1 -1
- package/BasicDynamic/index.tsx +66 -74
- package/BasicUpdateSize/index.tsx +65 -75
- package/Bounces/index.tsx +71 -55
- package/Bounces/styles.css +36 -27
- package/CHANGELOG.md +18 -0
- package/Common/Demo/styles.css +113 -0
- package/Custom/index.tsx +43 -41
- package/CustomScale/index.tsx +44 -42
- package/CustomTinder/index.tsx +2 -2
- package/CustomTinder/styles.css +1 -1
- package/DifferentHeight/Button.tsx +1 -29
- package/DifferentHeight/index.tsx +4 -4
- package/DifferentHeight/styles.css +1 -1
- package/Direction/index.tsx +97 -105
- package/EmptyDataBug/index.tsx +14 -13
- package/EmptyDataBug/styles.css +19 -12
- package/Indicator/index.tsx +56 -50
- package/Lazy/index.tsx +69 -65
- package/Loop/index.tsx +45 -42
- package/RTL/Button.tsx +1 -29
- package/RTL/index.tsx +74 -83
- package/RTLCustom/index.tsx +45 -43
- package/RTLLoop/Button.tsx +1 -29
- package/RTLLoop/index.tsx +57 -66
- package/RTLLoopLynxRTL/Button.tsx +1 -29
- package/RTLLoopLynxRTL/index.tsx +57 -66
- package/WithGap/Button.tsx +1 -29
- package/WithGap/index.tsx +57 -68
- package/dist/SwiperBasic.lynx.bundle +0 -0
- package/dist/SwiperBasic.web.bundle +1 -1
- package/dist/SwiperBasicDynamic.lynx.bundle +0 -0
- package/dist/SwiperBasicDynamic.web.bundle +1 -1
- package/dist/SwiperBasicUpdateSize.lynx.bundle +0 -0
- package/dist/SwiperBasicUpdateSize.web.bundle +1 -1
- package/dist/SwiperBounces.lynx.bundle +0 -0
- package/dist/SwiperBounces.web.bundle +1 -1
- package/dist/SwiperCustom.lynx.bundle +0 -0
- package/dist/SwiperCustom.web.bundle +1 -1
- package/dist/SwiperCustomScale.lynx.bundle +0 -0
- package/dist/SwiperCustomScale.web.bundle +1 -1
- package/dist/SwiperCustomTinder.lynx.bundle +0 -0
- package/dist/SwiperCustomTinder.web.bundle +1 -1
- package/dist/SwiperDifferentHeight.lynx.bundle +0 -0
- package/dist/SwiperDifferentHeight.web.bundle +1 -1
- package/dist/SwiperEmptyDataBug.lynx.bundle +0 -0
- package/dist/SwiperEmptyDataBug.web.bundle +1 -1
- package/dist/SwiperIndicator.lynx.bundle +0 -0
- package/dist/SwiperIndicator.web.bundle +1 -1
- package/dist/SwiperLazy.lynx.bundle +0 -0
- package/dist/SwiperLazy.web.bundle +1 -1
- package/dist/SwiperLoop.lynx.bundle +0 -0
- package/dist/SwiperLoop.web.bundle +1 -1
- package/dist/SwiperRTL.lynx.bundle +0 -0
- package/dist/SwiperRTL.web.bundle +1 -1
- package/dist/SwiperRTLCustom.lynx.bundle +0 -0
- package/dist/SwiperRTLCustom.web.bundle +1 -1
- package/dist/SwiperRTLLoop.lynx.bundle +0 -0
- package/dist/SwiperRTLLoop.web.bundle +1 -1
- package/dist/SwiperRTLLynxRTL.lynx.bundle +0 -0
- package/dist/SwiperRTLLynxRTL.web.bundle +1 -1
- package/dist/SwiperWithGap.lynx.bundle +0 -0
- package/dist/SwiperWithGap.web.bundle +1 -1
- package/package.json +6 -6
- package/BasicDynamic/styles.css +0 -47
- package/BasicUpdateSize/styles.css +0 -47
- package/Custom/styles.css +0 -47
- package/CustomScale/styles.css +0 -41
- package/Direction/styles.css +0 -41
- package/Indicator/styles.css +0 -41
- package/Lazy/styles.css +0 -41
- package/Loop/styles.css +0 -41
- package/RTL/styles.css +0 -41
- package/RTLCustom/styles.css +0 -41
- package/RTLLoop/styles.css +0 -41
- package/RTLLoopLynxRTL/styles.css +0 -41
- package/WithGap/styles.css +0 -47
package/RTLLoopLynxRTL/index.tsx
CHANGED
|
@@ -7,19 +7,13 @@ import { root, useRef, useState } from '@lynx-js/react'
|
|
|
7
7
|
import { Swiper, SwiperItem } from '@lynx-js/lynx-ui'
|
|
8
8
|
import type { SwiperRef } from '@lynx-js/lynx-ui'
|
|
9
9
|
|
|
10
|
-
import '
|
|
10
|
+
import { Button } from '../Common/Button'
|
|
11
|
+
import { Card } from '../Common/Card'
|
|
12
|
+
import { Indicator } from '../Common/Indicator'
|
|
11
13
|
|
|
12
|
-
import
|
|
14
|
+
import '../Common/Demo/styles.css'
|
|
13
15
|
|
|
14
|
-
const
|
|
15
|
-
'red',
|
|
16
|
-
'green',
|
|
17
|
-
'yellow',
|
|
18
|
-
'purple',
|
|
19
|
-
'lightblue',
|
|
20
|
-
'lightgreen',
|
|
21
|
-
'lightyellow',
|
|
22
|
-
]
|
|
16
|
+
const itemArr: number[] = [1, 2, 3, 4, 5, 6, 7]
|
|
23
17
|
|
|
24
18
|
const itemWidths = [250, 350, 400]
|
|
25
19
|
const alignArr: ['start', 'center', 'end'] = ['start', 'center', 'end']
|
|
@@ -31,81 +25,78 @@ function SwiperEntry(): JSX.Element {
|
|
|
31
25
|
const swiperRef = useRef<SwiperRef>(null)
|
|
32
26
|
|
|
33
27
|
return (
|
|
34
|
-
<view
|
|
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
|
-
<view
|
|
28
|
+
<view className='demo-container lunaris-dark'>
|
|
29
|
+
<view className='top-area' />
|
|
30
|
+
<view className='content-area'>
|
|
31
|
+
<Swiper
|
|
32
|
+
ref={swiperRef}
|
|
33
|
+
data={itemArr}
|
|
34
|
+
itemWidth={itemWidths[itemWidthsIndex] ?? 0}
|
|
35
|
+
itemHeight={250}
|
|
36
|
+
containerWidth={lynx.__globalProps.screenWidth - 32
|
|
37
|
+
|| SystemInfo.pixelWidth / SystemInfo.pixelRatio - 32}
|
|
38
|
+
duration={500}
|
|
39
|
+
initialIndex={0}
|
|
40
|
+
onChange={setCurrentIndex}
|
|
41
|
+
mode='normal'
|
|
42
|
+
modeConfig={{
|
|
43
|
+
align: alignArr[alignIndex] ?? 'start',
|
|
44
|
+
spaceBetween: 16,
|
|
45
|
+
}}
|
|
46
|
+
RTL={'lynx-rtl'}
|
|
47
|
+
loop={true}
|
|
48
|
+
style={{
|
|
49
|
+
overflow: 'visible',
|
|
50
|
+
}}
|
|
51
|
+
>
|
|
52
|
+
{({ index }) => (
|
|
53
|
+
<SwiperItem>
|
|
54
|
+
<Card
|
|
55
|
+
index={index}
|
|
65
56
|
style={{
|
|
66
|
-
|
|
67
|
-
width: '4px',
|
|
68
|
-
height: '4px',
|
|
57
|
+
height: '250px',
|
|
69
58
|
}}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
</view>
|
|
59
|
+
/>
|
|
60
|
+
</SwiperItem>
|
|
61
|
+
)}
|
|
62
|
+
</Swiper>
|
|
63
|
+
<Indicator
|
|
64
|
+
current={currentIndex}
|
|
65
|
+
count={itemArr.length}
|
|
66
|
+
/>
|
|
67
|
+
</view>
|
|
68
|
+
<view className='operation'>
|
|
81
69
|
<Button
|
|
82
70
|
onClick={() => {
|
|
83
71
|
swiperRef.current?.swipePrev()
|
|
84
72
|
}}
|
|
73
|
+
className='expand'
|
|
85
74
|
text='SwipePrev'
|
|
86
|
-
|
|
87
|
-
</Button>
|
|
75
|
+
/>
|
|
88
76
|
<Button
|
|
89
77
|
onClick={() => {
|
|
90
78
|
swiperRef.current?.swipeNext()
|
|
91
79
|
}}
|
|
80
|
+
className='expand'
|
|
81
|
+
type='primary'
|
|
92
82
|
text='SwipeNext'
|
|
93
|
-
|
|
94
|
-
|
|
83
|
+
/>
|
|
84
|
+
</view>
|
|
85
|
+
<view className='sub-operation'>
|
|
95
86
|
<Button
|
|
96
87
|
onClick={() => {
|
|
97
88
|
setItemWidthsIndex(prev => (prev + 1) % itemWidths.length)
|
|
98
89
|
}}
|
|
99
|
-
text=
|
|
100
|
-
|
|
101
|
-
|
|
90
|
+
text='Change Item Width'
|
|
91
|
+
subText={`ItemWidth: ${itemWidths[itemWidthsIndex]}`}
|
|
92
|
+
/>
|
|
102
93
|
<Button
|
|
103
94
|
onClick={() => {
|
|
104
95
|
setAlignIndex(prev => (prev + 1) % itemWidths.length)
|
|
105
96
|
}}
|
|
106
|
-
text=
|
|
107
|
-
|
|
108
|
-
|
|
97
|
+
text='Change Align Type'
|
|
98
|
+
subText={`AlignType: ${alignArr[alignIndex]}`}
|
|
99
|
+
/>
|
|
109
100
|
</view>
|
|
110
101
|
</view>
|
|
111
102
|
)
|
package/WithGap/Button.tsx
CHANGED
|
@@ -2,32 +2,4 @@
|
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
import { Button as ButtonInner } from '@lynx-js/lynx-ui'
|
|
7
|
-
|
|
8
|
-
const ButtonStyle = {
|
|
9
|
-
border: '1px solid',
|
|
10
|
-
'border-radius': '4px',
|
|
11
|
-
width: '150px',
|
|
12
|
-
'background-color': 'red',
|
|
13
|
-
margin: '4px 8px',
|
|
14
|
-
padding: '4px 8px',
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const ButtonTextStyle = {
|
|
18
|
-
color: 'white',
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function Button(props: {
|
|
22
|
-
onClick: () => void
|
|
23
|
-
text: string
|
|
24
|
-
}) {
|
|
25
|
-
return (
|
|
26
|
-
<ButtonInner
|
|
27
|
-
style={ButtonStyle}
|
|
28
|
-
onClick={props.onClick}
|
|
29
|
-
>
|
|
30
|
-
<text style={ButtonTextStyle}>{props.text}</text>
|
|
31
|
-
</ButtonInner>
|
|
32
|
-
)
|
|
33
|
-
}
|
|
5
|
+
export { Button } from '../Common/Button'
|
package/WithGap/index.tsx
CHANGED
|
@@ -7,20 +7,13 @@ import { root, useRef, useState } from '@lynx-js/react'
|
|
|
7
7
|
import { Swiper, SwiperItem } from '@lynx-js/lynx-ui'
|
|
8
8
|
import type { SwiperRef } from '@lynx-js/lynx-ui'
|
|
9
9
|
|
|
10
|
-
import '
|
|
10
|
+
import { Button } from '../Common/Button'
|
|
11
|
+
import { Card } from '../Common/Card'
|
|
12
|
+
import { Indicator } from '../Common/Indicator'
|
|
11
13
|
|
|
12
|
-
import
|
|
14
|
+
import '../Common/Demo/styles.css'
|
|
13
15
|
|
|
14
|
-
const
|
|
15
|
-
'red',
|
|
16
|
-
'green',
|
|
17
|
-
'yellow',
|
|
18
|
-
'purple',
|
|
19
|
-
'lightgreen',
|
|
20
|
-
'lightyellow',
|
|
21
|
-
'lightblue',
|
|
22
|
-
'gray',
|
|
23
|
-
]
|
|
16
|
+
const itemArr: number[] = [1, 2, 3, 4, 5, 6, 7, 8]
|
|
24
17
|
|
|
25
18
|
const itemWidths = [250, 350, 400]
|
|
26
19
|
const alignArr: ['start', 'center', 'end'] = ['start', 'center', 'end']
|
|
@@ -30,84 +23,80 @@ function SwiperEntry(): JSX.Element {
|
|
|
30
23
|
const [alignIndex, setAlignIndex] = useState<number>(0)
|
|
31
24
|
const [currentIndex, setCurrentIndex] = useState<number>(0)
|
|
32
25
|
const swiperRef = useRef<SwiperRef>(null)
|
|
33
|
-
const [colorsArr, _setColorsArr] = useState<string[]>(DEFAULT_COLORS_ARR)
|
|
34
26
|
|
|
35
27
|
return (
|
|
36
|
-
<view
|
|
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
|
-
<view
|
|
28
|
+
<view className='demo-container lunaris-dark'>
|
|
29
|
+
<view className='top-area' />
|
|
30
|
+
<view className='content-area'>
|
|
31
|
+
<Swiper
|
|
32
|
+
ref={swiperRef}
|
|
33
|
+
data={itemArr}
|
|
34
|
+
itemWidth={itemWidths[itemWidthsIndex] ?? 0}
|
|
35
|
+
itemHeight={250}
|
|
36
|
+
containerWidth={lynx.__globalProps.screenWidth - 32
|
|
37
|
+
|| SystemInfo.pixelWidth / SystemInfo.pixelRatio - 32}
|
|
38
|
+
duration={500}
|
|
39
|
+
initialIndex={0}
|
|
40
|
+
onChange={setCurrentIndex}
|
|
41
|
+
mode='normal'
|
|
42
|
+
loop={false}
|
|
43
|
+
autoPlay={true}
|
|
44
|
+
modeConfig={{
|
|
45
|
+
align: alignArr[alignIndex] ?? 'start',
|
|
46
|
+
spaceBetween: 16,
|
|
47
|
+
}}
|
|
48
|
+
style={{
|
|
49
|
+
overflow: 'visible',
|
|
50
|
+
}}
|
|
51
|
+
>
|
|
52
|
+
{({ index }) => (
|
|
53
|
+
<SwiperItem>
|
|
54
|
+
<Card
|
|
55
|
+
index={index}
|
|
67
56
|
style={{
|
|
68
|
-
|
|
69
|
-
width: '4px',
|
|
70
|
-
height: '4px',
|
|
57
|
+
height: '250px',
|
|
71
58
|
}}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
</view>
|
|
59
|
+
/>
|
|
60
|
+
</SwiperItem>
|
|
61
|
+
)}
|
|
62
|
+
</Swiper>
|
|
63
|
+
<Indicator
|
|
64
|
+
current={currentIndex}
|
|
65
|
+
count={itemArr.length}
|
|
66
|
+
/>
|
|
67
|
+
</view>
|
|
68
|
+
<view className='operation'>
|
|
83
69
|
<Button
|
|
84
70
|
onClick={() => {
|
|
85
71
|
swiperRef.current?.swipePrev()
|
|
86
72
|
}}
|
|
73
|
+
className='expand'
|
|
87
74
|
text='SwipePrev'
|
|
88
|
-
|
|
89
|
-
</Button>
|
|
75
|
+
/>
|
|
90
76
|
<Button
|
|
91
77
|
onClick={() => {
|
|
92
78
|
swiperRef.current?.swipeNext()
|
|
93
79
|
}}
|
|
80
|
+
className='expand'
|
|
81
|
+
type='primary'
|
|
94
82
|
text='SwipeNext'
|
|
95
|
-
|
|
96
|
-
|
|
83
|
+
/>
|
|
84
|
+
</view>
|
|
85
|
+
<view className='sub-operation'>
|
|
97
86
|
<Button
|
|
98
87
|
onClick={() => {
|
|
99
88
|
setItemWidthsIndex(prev => (prev + 1) % itemWidths.length)
|
|
100
89
|
}}
|
|
101
|
-
text=
|
|
102
|
-
|
|
103
|
-
|
|
90
|
+
text='Change Item Width'
|
|
91
|
+
subText={`ItemWidth: ${itemWidths[itemWidthsIndex]}`}
|
|
92
|
+
/>
|
|
104
93
|
<Button
|
|
105
94
|
onClick={() => {
|
|
106
95
|
setAlignIndex(prev => (prev + 1) % itemWidths.length)
|
|
107
96
|
}}
|
|
108
|
-
text=
|
|
109
|
-
|
|
110
|
-
|
|
97
|
+
text='Change Align Type'
|
|
98
|
+
subText={`AlignType: ${alignArr[alignIndex]}`}
|
|
99
|
+
/>
|
|
111
100
|
</view>
|
|
112
101
|
</view>
|
|
113
102
|
)
|
|
Binary file
|