@lynx-example/lynx-ui-swiper 0.0.1 → 0.0.2

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.
Files changed (62) hide show
  1. package/Basic/index.tsx +109 -0
  2. package/Basic/styles.css +49 -0
  3. package/BasicDynamic/index.tsx +130 -0
  4. package/BasicDynamic/styles.css +47 -0
  5. package/BasicUpdateSize/index.tsx +131 -0
  6. package/BasicUpdateSize/styles.css +47 -0
  7. package/Bounces/index.tsx +73 -0
  8. package/Bounces/styles.css +41 -0
  9. package/CHANGELOG.md +8 -0
  10. package/Common/Button/index.tsx +48 -0
  11. package/Common/Button/styles.css +41 -0
  12. package/Common/Card/index.tsx +21 -0
  13. package/Common/Card/styles.css +21 -0
  14. package/Common/Indicator/index.tsx +24 -0
  15. package/Common/Indicator/styles.css +21 -0
  16. package/Custom/index.tsx +87 -0
  17. package/Custom/styles.css +47 -0
  18. package/CustomScale/index.tsx +116 -0
  19. package/CustomScale/styles.css +41 -0
  20. package/CustomTinder/Card.tsx +24 -0
  21. package/CustomTinder/index.tsx +111 -0
  22. package/CustomTinder/styles.css +61 -0
  23. package/DifferentHeight/Button.tsx +33 -0
  24. package/DifferentHeight/index.tsx +95 -0
  25. package/DifferentHeight/styles.css +50 -0
  26. package/Direction/index.tsx +127 -0
  27. package/Direction/styles.css +41 -0
  28. package/EmptyDataBug/index.tsx +371 -0
  29. package/EmptyDataBug/styles.css +75 -0
  30. package/Indicator/index.tsx +67 -0
  31. package/Indicator/styles.css +41 -0
  32. package/Lazy/index.tsx +83 -0
  33. package/Lazy/styles.css +41 -0
  34. package/Loop/index.tsx +77 -0
  35. package/Loop/styles.css +41 -0
  36. package/RTL/Button.tsx +33 -0
  37. package/RTL/index.tsx +133 -0
  38. package/RTL/styles.css +41 -0
  39. package/RTLCustom/index.tsx +115 -0
  40. package/RTLCustom/styles.css +41 -0
  41. package/RTLLoop/Button.tsx +33 -0
  42. package/RTLLoop/index.tsx +116 -0
  43. package/RTLLoop/styles.css +41 -0
  44. package/RTLLoopLynxRTL/Button.tsx +33 -0
  45. package/RTLLoopLynxRTL/index.tsx +116 -0
  46. package/RTLLoopLynxRTL/styles.css +41 -0
  47. package/WithGap/Button.tsx +33 -0
  48. package/WithGap/index.tsx +118 -0
  49. package/WithGap/styles.css +47 -0
  50. package/dist/SwiperBasic.lynx.bundle +0 -0
  51. package/dist/SwiperBasic.web.bundle +1 -1
  52. package/dist/SwiperBasicDynamic.lynx.bundle +0 -0
  53. package/dist/SwiperBasicDynamic.web.bundle +1 -1
  54. package/dist/SwiperBasicUpdateSize.lynx.bundle +0 -0
  55. package/dist/SwiperBasicUpdateSize.web.bundle +1 -1
  56. package/dist/SwiperCustomTinder.lynx.bundle +0 -0
  57. package/dist/SwiperCustomTinder.web.bundle +1 -1
  58. package/dist/SwiperDifferentHeight.lynx.bundle +0 -0
  59. package/dist/SwiperDifferentHeight.web.bundle +1 -1
  60. package/dist/SwiperEmptyDataBug.lynx.bundle +0 -0
  61. package/dist/SwiperEmptyDataBug.web.bundle +1 -1
  62. package/package.json +4 -2
@@ -0,0 +1,75 @@
1
+ .container {
2
+ width: 100%;
3
+ height: 100%;
4
+ padding: 16px;
5
+ box-sizing: border-box;
6
+ }
7
+
8
+ .main-title {
9
+ font-size: 24px;
10
+ font-weight: bold;
11
+ margin-bottom: 8px;
12
+ color: #333;
13
+ }
14
+
15
+ .main-description {
16
+ font-size: 14px;
17
+ color: #666;
18
+ margin-bottom: 24px;
19
+ line-height: 1.5;
20
+ }
21
+
22
+ .section {
23
+ margin-bottom: 32px;
24
+ padding: 16px;
25
+ background-color: #f5f5f5;
26
+ border-radius: 8px;
27
+ }
28
+
29
+ .title {
30
+ font-size: 16px;
31
+ font-weight: bold;
32
+ margin-bottom: 8px;
33
+ color: #333;
34
+ }
35
+
36
+ .description {
37
+ font-size: 12px;
38
+ color: #888;
39
+ margin-bottom: 16px;
40
+ line-height: 1.4;
41
+ }
42
+
43
+ .buttons {
44
+ display: flex;
45
+ flex-wrap: wrap;
46
+ gap: 8px;
47
+ margin-top: 16px;
48
+ }
49
+
50
+ .info {
51
+ display: flex;
52
+ flex-direction: column;
53
+ gap: 4px;
54
+ margin-top: 12px;
55
+ padding: 8px;
56
+ background-color: #e8e8e8;
57
+ border-radius: 4px;
58
+ }
59
+
60
+ .info text {
61
+ font-size: 12px;
62
+ color: #666;
63
+ }
64
+
65
+ .log-title {
66
+ font-weight: bold;
67
+ margin-top: 8px;
68
+ color: #333;
69
+ }
70
+
71
+ .log-item {
72
+ font-size: 11px;
73
+ color: #888;
74
+ padding-left: 8px;
75
+ }
@@ -0,0 +1,67 @@
1
+ // Copyright 2026 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+
5
+ import { root } from '@lynx-js/react'
6
+
7
+ import { Swiper, SwiperItem } from '@lynx-js/lynx-ui'
8
+
9
+ import './styles.css'
10
+
11
+ const colorsArr: string[] = ['red', 'green', 'yellow', 'purple']
12
+
13
+ function SwiperEntry() {
14
+ return (
15
+ <Swiper
16
+ data={colorsArr}
17
+ itemWidth={375}
18
+ itemHeight={200}
19
+ loop={false}
20
+ duration={500}
21
+ initialIndex={0}
22
+ mode='normal'
23
+ bounceConfig={{
24
+ enable: true,
25
+ startBounceItemWidth: 100,
26
+ startBounceItem: (
27
+ <view>
28
+ <text>123</text>
29
+ </view>
30
+ ),
31
+ }}
32
+ onChange={i => {
33
+ console.log('change', i)
34
+ }}
35
+ >
36
+ {({ item, index, realIndex }) => (
37
+ <SwiperItem index={index} key={realIndex} realIndex={realIndex}>
38
+ <view
39
+ class='block-view'
40
+ style={{
41
+ width: '100%',
42
+ height: '100%',
43
+ backgroundColor: item,
44
+ display: 'flex',
45
+ justifyContent: 'center',
46
+ alignItems: 'center',
47
+ }}
48
+ >
49
+ <view
50
+ style={{
51
+ backgroundColor: 'white',
52
+ width: '4px',
53
+ height: '4px',
54
+ }}
55
+ >
56
+ </view>
57
+ </view>
58
+ <text class='image-text'>Number.{index}</text>
59
+ </SwiperItem>
60
+ )}
61
+ </Swiper>
62
+ )
63
+ }
64
+
65
+ root.render(<SwiperEntry />)
66
+
67
+ export default SwiperEntry
@@ -0,0 +1,41 @@
1
+ .image {
2
+ width: 100%;
3
+ height: 100%;
4
+ }
5
+
6
+ .image-text {
7
+ position: absolute;
8
+ }
9
+
10
+ .container {
11
+ width: 100%;
12
+ height: 100%;
13
+ }
14
+
15
+ .title-container {
16
+ margin-top: 10px;
17
+ margin-bottom: 5px;
18
+ }
19
+
20
+ .title-text {
21
+ font-size: 16px;
22
+ }
23
+
24
+ .button {
25
+ border: 1px solid;
26
+ border-radius: 4px;
27
+ width: 150px;
28
+ background-color: red;
29
+ margin: 4px 8px;
30
+ padding: 4px 8px;
31
+ }
32
+
33
+ .button-text {
34
+ color: white;
35
+ }
36
+
37
+ .operation {
38
+ display: flex;
39
+ align-items: center;
40
+ flex-wrap: wrap;
41
+ }
package/Lazy/index.tsx ADDED
@@ -0,0 +1,83 @@
1
+ // Copyright 2026 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+
5
+ import { root } from '@lynx-js/react'
6
+
7
+ import { LazyComponent, Swiper, SwiperItem } from '@lynx-js/lynx-ui'
8
+
9
+ import './styles.css'
10
+
11
+ const colorsArr: string[] = [
12
+ 'red',
13
+ 'green',
14
+ 'yellow',
15
+ 'purple',
16
+ 'lightblue',
17
+ 'lightgreen',
18
+ 'lightyellow',
19
+ ]
20
+
21
+ function SwiperEntry() {
22
+ return (
23
+ <Swiper
24
+ data={colorsArr}
25
+ itemWidth={250}
26
+ itemHeight={200}
27
+ loop={false}
28
+ duration={500}
29
+ initialIndex={0}
30
+ mode='normal'
31
+ modeConfig={{
32
+ align: 'start',
33
+ }}
34
+ bounceConfig={{
35
+ enable: true,
36
+ startBounceItemWidth: 0,
37
+ endBounceItem: (
38
+ <view style='display: linear; linear-orientation: vertical; height: 100%; width: 30px; border: 1px solid #000;'>
39
+ <text style='color: #000'>Show More</text>
40
+ </view>
41
+ ),
42
+ onEndBounceItemBounce: ({ type }) => {
43
+ console.log('onBounce result', type)
44
+ },
45
+ }}
46
+ >
47
+ {({ item, index, realIndex }) => (
48
+ <SwiperItem index={index} key={realIndex} realIndex={realIndex}>
49
+ <LazyComponent
50
+ scene='scene'
51
+ pid={`pid_${realIndex}`}
52
+ estimatedStyle={{ width: '100%', height: '100%' }}
53
+ >
54
+ <view
55
+ class='block-view'
56
+ style={{
57
+ width: '100%',
58
+ height: '100%',
59
+ backgroundColor: item,
60
+ display: 'flex',
61
+ justifyContent: 'center',
62
+ alignItems: 'center',
63
+ }}
64
+ >
65
+ <view
66
+ style={{
67
+ backgroundColor: 'white',
68
+ width: '4px',
69
+ height: '4px',
70
+ }}
71
+ >
72
+ </view>
73
+ </view>
74
+ </LazyComponent>
75
+ </SwiperItem>
76
+ )}
77
+ </Swiper>
78
+ )
79
+ }
80
+
81
+ root.render(<SwiperEntry />)
82
+
83
+ export default SwiperEntry
@@ -0,0 +1,41 @@
1
+ .image {
2
+ width: 100%;
3
+ height: 100%;
4
+ }
5
+
6
+ .image-text {
7
+ position: absolute;
8
+ }
9
+
10
+ .container {
11
+ width: 100%;
12
+ height: 100%;
13
+ }
14
+
15
+ .title-container {
16
+ margin-top: 10px;
17
+ margin-bottom: 5px;
18
+ }
19
+
20
+ .title-text {
21
+ font-size: 16px;
22
+ }
23
+
24
+ .button {
25
+ border: 1px solid;
26
+ border-radius: 4px;
27
+ width: 150px;
28
+ background-color: red;
29
+ margin: 4px 8px;
30
+ padding: 4px 8px;
31
+ }
32
+
33
+ .button-text {
34
+ color: white;
35
+ }
36
+
37
+ .operation {
38
+ display: flex;
39
+ align-items: center;
40
+ flex-wrap: wrap;
41
+ }
package/Loop/index.tsx ADDED
@@ -0,0 +1,77 @@
1
+ // Copyright 2026 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+
5
+ import { root, useState } from '@lynx-js/react'
6
+
7
+ import { Swiper, SwiperItem } from '@lynx-js/lynx-ui'
8
+
9
+ import './styles.css'
10
+
11
+ const colorsArr: string[] = ['red', 'green', 'yellow', 'purple']
12
+
13
+ function SwiperEntry() {
14
+ const [currentIndex, setCurrentIndex] = useState(0)
15
+ const SwiperItemGap = 8
16
+ const screenWidth = lynx.__globalProps.screenWidth
17
+ ?? SystemInfo.pixelWidth / SystemInfo.pixelRatio
18
+ const containWidth = (screenWidth || 375) - SwiperItemGap * 2
19
+ const itemWidth = ((screenWidth || 375) / 375) * 315
20
+
21
+ console.log(
22
+ 'screenWidth, itemWidth, containWidth',
23
+ screenWidth,
24
+ itemWidth,
25
+ containWidth,
26
+ )
27
+ return (
28
+ <view>
29
+ <Swiper
30
+ data={colorsArr}
31
+ itemWidth={itemWidth + SwiperItemGap}
32
+ itemHeight={219.92727272727276}
33
+ containerWidth={containWidth}
34
+ loop={true}
35
+ duration={500}
36
+ initialIndex={0}
37
+ mode='normal'
38
+ autoPlay={true}
39
+ onChange={setCurrentIndex}
40
+ experimentalHorizontalSwipeOnly={true}
41
+ >
42
+ {({ item, index, realIndex }) => (
43
+ <SwiperItem index={index} key={realIndex} realIndex={realIndex}>
44
+ <view
45
+ class='block-view'
46
+ style={{
47
+ width: '100%',
48
+ height: '100%',
49
+ backgroundColor: item,
50
+ display: 'flex',
51
+ justifyContent: 'center',
52
+ alignItems: 'center',
53
+ }}
54
+ >
55
+ <view
56
+ style={{
57
+ backgroundColor: 'white',
58
+ width: '4px',
59
+ height: '4px',
60
+ }}
61
+ >
62
+ </view>
63
+ </view>
64
+ <text class='image-text'>Number.{index}</text>
65
+ </SwiperItem>
66
+ )}
67
+ </Swiper>
68
+ <view>
69
+ <text>currentIndex: {currentIndex}</text>
70
+ </view>
71
+ </view>
72
+ )
73
+ }
74
+
75
+ root.render(<SwiperEntry />)
76
+
77
+ export default SwiperEntry
@@ -0,0 +1,41 @@
1
+ .image {
2
+ width: 100%;
3
+ height: 100%;
4
+ }
5
+
6
+ .image-text {
7
+ position: absolute;
8
+ }
9
+
10
+ .container {
11
+ width: 100%;
12
+ height: 100%;
13
+ }
14
+
15
+ .title-container {
16
+ margin-top: 10px;
17
+ margin-bottom: 5px;
18
+ }
19
+
20
+ .title-text {
21
+ font-size: 16px;
22
+ }
23
+
24
+ .button {
25
+ border: 1px solid;
26
+ border-radius: 4px;
27
+ width: 150px;
28
+ background-color: red;
29
+ margin: 4px 8px;
30
+ padding: 4px 8px;
31
+ }
32
+
33
+ .button-text {
34
+ color: white;
35
+ }
36
+
37
+ .operation {
38
+ display: flex;
39
+ align-items: center;
40
+ flex-wrap: wrap;
41
+ }
package/RTL/Button.tsx ADDED
@@ -0,0 +1,33 @@
1
+ // Copyright 2026 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+
5
+ import './styles.css'
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
+ }
package/RTL/index.tsx ADDED
@@ -0,0 +1,133 @@
1
+ // Copyright 2026 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+
5
+ import { root, useRef, useState } from '@lynx-js/react'
6
+
7
+ import { Swiper, SwiperItem } from '@lynx-js/lynx-ui'
8
+ import type { SwiperRef } from '@lynx-js/lynx-ui'
9
+
10
+ import './styles.css'
11
+
12
+ import { Button } from './Button'
13
+
14
+ const colorsArr: string[] = [
15
+ 'red',
16
+ 'green',
17
+ 'yellow',
18
+ 'purple',
19
+ 'lightblue',
20
+ 'lightgreen',
21
+ 'lightyellow',
22
+ ]
23
+
24
+ const itemWidths = [250, 350, 400]
25
+ const alignArr: ['start', 'center', 'end'] = ['start', 'center', 'end']
26
+
27
+ function SwiperEntry(): JSX.Element {
28
+ const [itemWidthsIndex, setItemWidthsIndex] = useState<number>(0)
29
+ const [alignIndex, setAlignIndex] = useState<number>(0)
30
+ const [currentIndex, setCurrentIndex] = useState<number>(0)
31
+ const swiperRef = useRef<SwiperRef>(null)
32
+
33
+ return (
34
+ <view id='container'>
35
+ <Swiper
36
+ ref={swiperRef}
37
+ data={colorsArr}
38
+ itemWidth={itemWidths[itemWidthsIndex] ?? 0}
39
+ itemHeight={200}
40
+ duration={500}
41
+ initialIndex={0}
42
+ onChange={setCurrentIndex}
43
+ mode='normal'
44
+ modeConfig={{
45
+ align: alignArr[alignIndex] ?? 'start',
46
+ spaceBetween: 8,
47
+ }}
48
+ RTL={true}
49
+ bounceConfig={{
50
+ enable: true,
51
+ startBounceItemWidth: 100,
52
+ endBounceItemWidth: 100,
53
+ startBounceItem: (
54
+ <view style='display: linear; linear-orientation: vertical; height: 100%; width: 30px; border: 1px solid #000;'>
55
+ <text style='color: #000'>Start Show More</text>
56
+ </view>
57
+ ),
58
+ endBounceItem: (
59
+ <view style='display: linear; linear-orientation: vertical; height: 100%; width: 30px; border: 1px solid #000;'>
60
+ <text style='color: #000'>Show More</text>
61
+ </view>
62
+ ),
63
+ onEndBounceItemBounce: ({ type }) => {
64
+ console.log('onBounce result', type)
65
+ },
66
+ }}
67
+ >
68
+ {({ item, index, realIndex }) => (
69
+ <SwiperItem index={index} key={realIndex} realIndex={realIndex}>
70
+ <view
71
+ class='block-view'
72
+ style={{
73
+ width: '100%',
74
+ height: '100%',
75
+ backgroundColor: item,
76
+ display: 'flex',
77
+ justifyContent: 'center',
78
+ alignItems: 'center',
79
+ }}
80
+ >
81
+ <view
82
+ style={{
83
+ backgroundColor: 'white',
84
+ width: '4px',
85
+ height: '4px',
86
+ }}
87
+ >
88
+ </view>
89
+ </view>
90
+ <text class='image-text'>Number.{index}</text>
91
+ </SwiperItem>
92
+ )}
93
+ </Swiper>
94
+ <view class='operation'>
95
+ <view class='block'>
96
+ <text>Current Index: {currentIndex}</text>
97
+ </view>
98
+ <Button
99
+ onClick={() => {
100
+ swiperRef.current?.swipePrev()
101
+ }}
102
+ text='SwipePrev'
103
+ >
104
+ </Button>
105
+ <Button
106
+ onClick={() => {
107
+ swiperRef.current?.swipeNext()
108
+ }}
109
+ text='SwipeNext'
110
+ >
111
+ </Button>
112
+ <Button
113
+ onClick={() => {
114
+ setItemWidthsIndex(prev => (prev + 1) % itemWidths.length)
115
+ }}
116
+ text={`itemWidth: ${itemWidths[itemWidthsIndex]}`}
117
+ >
118
+ </Button>
119
+ <Button
120
+ onClick={() => {
121
+ setAlignIndex(prev => (prev + 1) % itemWidths.length)
122
+ }}
123
+ text={`alignType: ${alignArr[alignIndex]}`}
124
+ >
125
+ </Button>
126
+ </view>
127
+ </view>
128
+ )
129
+ }
130
+
131
+ root.render(<SwiperEntry />)
132
+
133
+ export default SwiperEntry
package/RTL/styles.css ADDED
@@ -0,0 +1,41 @@
1
+ .image {
2
+ width: 100%;
3
+ height: 100%;
4
+ }
5
+
6
+ .image-text {
7
+ position: absolute;
8
+ }
9
+
10
+ .container {
11
+ width: 100%;
12
+ height: 100%;
13
+ }
14
+
15
+ .title-container {
16
+ margin-top: 10px;
17
+ margin-bottom: 5px;
18
+ }
19
+
20
+ .title-text {
21
+ font-size: 16px;
22
+ }
23
+
24
+ .button {
25
+ border: 1px solid;
26
+ border-radius: 4px;
27
+ width: 150px;
28
+ background-color: red;
29
+ margin: 4px 8px;
30
+ padding: 4px 8px;
31
+ }
32
+
33
+ .button-text {
34
+ color: white;
35
+ }
36
+
37
+ .operation {
38
+ display: flex;
39
+ align-items: center;
40
+ flex-wrap: wrap;
41
+ }