@lynx-example/lynx-ui-scroll-view 0.0.15 → 0.0.17
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.css +2 -47
- package/Basic/index.tsx +7 -2
- package/Bounces/index.css +36 -0
- package/Bounces/index.tsx +61 -0
- package/BouncesRTL/index.css +41 -0
- package/BouncesRTL/index.tsx +63 -0
- package/CHANGELOG.md +19 -0
- package/NativeUseBounces/index.css +136 -0
- package/NativeUseBounces/index.tsx +155 -0
- package/ScrollBy/index.css +19 -11
- package/ScrollBy/index.tsx +16 -10
- package/ZIndex/data.ts +47 -0
- package/ZIndex/index.css +39 -9
- package/ZIndex/index.tsx +14 -16
- package/dist/ScrollViewBasic.lynx.bundle +0 -0
- package/dist/ScrollViewBounces.lynx.bundle +0 -0
- package/dist/ScrollViewBouncesRTL.lynx.bundle +0 -0
- package/dist/ScrollViewInnerFlex.lynx.bundle +0 -0
- package/dist/ScrollViewNativeUseBounces.lynx.bundle +0 -0
- package/dist/ScrollViewScrollBy.lynx.bundle +0 -0
- package/dist/ScrollViewZIndex.lynx.bundle +0 -0
- package/lynx.config.mjs +3 -2
- package/package.json +4 -3
- package/shared/BounceTag/index.css +37 -0
- package/shared/BounceTag/index.tsx +27 -0
- package/shared/CircleCard/index.css +7 -0
- package/shared/CircleCard/index.tsx +35 -0
- package/{HorizontalRTL/index.css → shared/base.css} +2 -54
- package/Basic/CircleLetterCard.tsx +0 -23
- package/Horizontal/index.css +0 -110
- package/Horizontal/index.tsx +0 -75
- package/HorizontalRTL/index.tsx +0 -76
- package/dist/ScrollViewHorizontal.lynx.bundle +0 -0
- package/dist/ScrollViewHorizontalRTL.lynx.bundle +0 -0
package/Basic/index.css
CHANGED
|
@@ -1,58 +1,13 @@
|
|
|
1
1
|
@import "@lynx-js/luna-styles/index.css";
|
|
2
2
|
|
|
3
|
+
@import "../shared/base.css";
|
|
4
|
+
|
|
3
5
|
.demo-container {
|
|
4
|
-
background-color: var(--canvas);
|
|
5
|
-
width: 100%;
|
|
6
|
-
height: 100%;
|
|
7
6
|
padding-top: 48px;
|
|
8
7
|
padding-bottom: 24px;
|
|
9
|
-
display: flex;
|
|
10
|
-
align-items: center;
|
|
11
|
-
justify-content: center;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.card {
|
|
15
|
-
width: 288px;
|
|
16
|
-
height: 100%;
|
|
17
|
-
display: flex;
|
|
18
|
-
align-items: center;
|
|
19
|
-
justify-content: center;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.circle {
|
|
23
|
-
width: 216px;
|
|
24
|
-
height: 216px;
|
|
25
|
-
border-radius: 9999px;
|
|
26
|
-
background-color: var(--canvas);
|
|
27
|
-
padding-bottom: 45px;
|
|
28
|
-
display: flex;
|
|
29
|
-
flex-direction: column;
|
|
30
|
-
align-items: center;
|
|
31
|
-
justify-content: end;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.letter {
|
|
35
|
-
font-size: 96px;
|
|
36
|
-
font-weight: 600;
|
|
37
|
-
line-height: 96px;
|
|
38
|
-
color: var(--primary);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.title {
|
|
42
|
-
font-size: 16px;
|
|
43
|
-
font-weight: 600;
|
|
44
|
-
color: var(--content);
|
|
45
|
-
margin-top: 4px;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.subtitle {
|
|
49
|
-
font-size: 10px;
|
|
50
|
-
color: var(--content-subtle);
|
|
51
|
-
margin-top: 1px;
|
|
52
8
|
}
|
|
53
9
|
|
|
54
10
|
.scroll-view {
|
|
55
|
-
width: 100%;
|
|
56
11
|
height: 472px;
|
|
57
12
|
}
|
|
58
13
|
|
package/Basic/index.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import { root } from '@lynx-js/react'
|
|
|
6
6
|
|
|
7
7
|
import { ScrollView } from '@lynx-js/lynx-ui'
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { CircleCard } from '../shared/CircleCard'
|
|
10
10
|
import './index.css'
|
|
11
11
|
|
|
12
12
|
const LETTERS = ['L', 'Y', 'N', 'X', 'U', 'I', 'L', 'Y', 'N', 'X', 'J', 'S']
|
|
@@ -17,7 +17,12 @@ function App() {
|
|
|
17
17
|
<ScrollView scrollOrientation='horizontal' className='scroll-view'>
|
|
18
18
|
<view className='scroll-view-content'>
|
|
19
19
|
{LETTERS.map((letter, i) => (
|
|
20
|
-
<
|
|
20
|
+
<CircleCard
|
|
21
|
+
letter={letter}
|
|
22
|
+
title='ScrollView'
|
|
23
|
+
subtitle='@lynx-js/lynx-ui'
|
|
24
|
+
key={`circle-${i}`}
|
|
25
|
+
/>
|
|
21
26
|
))}
|
|
22
27
|
</view>
|
|
23
28
|
</ScrollView>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
@import "@lynx-js/luna-styles/index.css";
|
|
2
|
+
|
|
3
|
+
@import "../shared/base.css";
|
|
4
|
+
|
|
5
|
+
.demo-container {
|
|
6
|
+
padding-top: 48px;
|
|
7
|
+
padding-bottom: 24px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.demo-scroll-region {
|
|
11
|
+
width: 100%;
|
|
12
|
+
height: 472px;
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
background-color: var(--canvas-ambient);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.scroll-view {
|
|
19
|
+
height: 100%;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.scroll-view-content {
|
|
23
|
+
width: max-content;
|
|
24
|
+
height: 100%;
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: row;
|
|
27
|
+
padding-left: 40px;
|
|
28
|
+
padding-right: 40px;
|
|
29
|
+
background: linear-gradient(
|
|
30
|
+
90deg,
|
|
31
|
+
var(--gradient-a),
|
|
32
|
+
var(--gradient-b),
|
|
33
|
+
var(--gradient-c),
|
|
34
|
+
var(--gradient-d)
|
|
35
|
+
);
|
|
36
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
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 { ScrollView } from '@lynx-js/lynx-ui'
|
|
8
|
+
|
|
9
|
+
import { BounceTag } from '../shared/BounceTag'
|
|
10
|
+
import { CircleCard } from '../shared/CircleCard'
|
|
11
|
+
import './index.css'
|
|
12
|
+
|
|
13
|
+
const LETTERS = [
|
|
14
|
+
'L',
|
|
15
|
+
'Y',
|
|
16
|
+
'N',
|
|
17
|
+
'X',
|
|
18
|
+
'L',
|
|
19
|
+
'T',
|
|
20
|
+
'R',
|
|
21
|
+
'B',
|
|
22
|
+
'O',
|
|
23
|
+
'U',
|
|
24
|
+
'N',
|
|
25
|
+
'C',
|
|
26
|
+
'E',
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
function App() {
|
|
30
|
+
return (
|
|
31
|
+
<view className='demo-container lunaris-dark'>
|
|
32
|
+
<view className='demo-scroll-region'>
|
|
33
|
+
<ScrollView
|
|
34
|
+
scrollOrientation='horizontal'
|
|
35
|
+
className='scroll-view'
|
|
36
|
+
bounceableOptions={{
|
|
37
|
+
enableBounces: true,
|
|
38
|
+
alwaysBouncing: true,
|
|
39
|
+
upperBounceItem: <BounceTag label='Start Bounce' variant='upper' />,
|
|
40
|
+
lowerBounceItem: <BounceTag label='End Bounce' variant='lower' />,
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
<view className='scroll-view-content'>
|
|
44
|
+
{LETTERS.map((letter, index) => (
|
|
45
|
+
<CircleCard
|
|
46
|
+
letter={letter}
|
|
47
|
+
title='ScrollView Bounces'
|
|
48
|
+
subtitle='@lynx-js/lynx-ui'
|
|
49
|
+
key={`${letter}-${index}`}
|
|
50
|
+
/>
|
|
51
|
+
))}
|
|
52
|
+
</view>
|
|
53
|
+
</ScrollView>
|
|
54
|
+
</view>
|
|
55
|
+
</view>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
root.render(<App />)
|
|
60
|
+
|
|
61
|
+
export default App
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
@import "@lynx-js/luna-styles/index.css";
|
|
2
|
+
|
|
3
|
+
@import "../shared/base.css";
|
|
4
|
+
|
|
5
|
+
.demo-container {
|
|
6
|
+
padding-top: 48px;
|
|
7
|
+
padding-bottom: 24px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.demo-scroll-region {
|
|
11
|
+
width: 100%;
|
|
12
|
+
height: 472px;
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
background-color: var(--canvas-ambient);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.rtl-scope {
|
|
19
|
+
direction: rtl;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.scroll-view {
|
|
23
|
+
height: 100%;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.scroll-view-content {
|
|
27
|
+
width: max-content;
|
|
28
|
+
height: 100%;
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: row;
|
|
31
|
+
padding-left: 40px;
|
|
32
|
+
padding-right: 40px;
|
|
33
|
+
direction: inherit;
|
|
34
|
+
background: linear-gradient(
|
|
35
|
+
270deg,
|
|
36
|
+
var(--gradient-a),
|
|
37
|
+
var(--gradient-b),
|
|
38
|
+
var(--gradient-c),
|
|
39
|
+
var(--gradient-d)
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
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 { ScrollView } from '@lynx-js/lynx-ui'
|
|
8
|
+
|
|
9
|
+
import { BounceTag } from '../shared/BounceTag'
|
|
10
|
+
import { CircleCard } from '../shared/CircleCard'
|
|
11
|
+
import './index.css'
|
|
12
|
+
|
|
13
|
+
const LETTERS = [
|
|
14
|
+
'L',
|
|
15
|
+
'Y',
|
|
16
|
+
'N',
|
|
17
|
+
'X',
|
|
18
|
+
'R',
|
|
19
|
+
'T',
|
|
20
|
+
'L',
|
|
21
|
+
'B',
|
|
22
|
+
'O',
|
|
23
|
+
'U',
|
|
24
|
+
'N',
|
|
25
|
+
'C',
|
|
26
|
+
'E',
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
function App() {
|
|
30
|
+
return (
|
|
31
|
+
<view className='demo-container lunaris-dark rtl-scope'>
|
|
32
|
+
<view className='demo-scroll-region'>
|
|
33
|
+
<ScrollView
|
|
34
|
+
scrollOrientation='horizontal'
|
|
35
|
+
enableRTL={true}
|
|
36
|
+
className='scroll-view'
|
|
37
|
+
bounceableOptions={{
|
|
38
|
+
enableBounces: true,
|
|
39
|
+
alwaysBouncing: true,
|
|
40
|
+
upperBounceItem: <BounceTag label='Start Bounce' variant='upper' />,
|
|
41
|
+
lowerBounceItem: <BounceTag label='End Bounce' variant='lower' />,
|
|
42
|
+
}}
|
|
43
|
+
>
|
|
44
|
+
<view className='scroll-view-content'>
|
|
45
|
+
{LETTERS.map((letter, index) => (
|
|
46
|
+
<CircleCard
|
|
47
|
+
letter={letter}
|
|
48
|
+
title='Bounces RTL'
|
|
49
|
+
subtitle='@lynx-js/lynx-ui'
|
|
50
|
+
subtitleDirection='ltr'
|
|
51
|
+
key={`${letter}-${index}`}
|
|
52
|
+
/>
|
|
53
|
+
))}
|
|
54
|
+
</view>
|
|
55
|
+
</ScrollView>
|
|
56
|
+
</view>
|
|
57
|
+
</view>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
root.render(<App />)
|
|
62
|
+
|
|
63
|
+
export default App
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @lynx-example/lynx-ui-scroll-view
|
|
2
2
|
|
|
3
|
+
## 0.0.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies []:
|
|
8
|
+
- @lynx-js/lynx-ui@3.137.0
|
|
9
|
+
|
|
10
|
+
## 0.0.16
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Rename the horizontal bounce demos to Bounces and BouncesRTL, and ([#266](https://github.com/lynx-family/lynx-ui/pull/266))
|
|
15
|
+
refine ScrollView example layout, gradients, shared primitives, and
|
|
16
|
+
surface layering to improve bounce demos, button styling, and RTL text
|
|
17
|
+
behavior.
|
|
18
|
+
- Updated dependencies [[`4214d92`](https://github.com/lynx-family/lynx-ui/commit/4214d923421d0a61ecd0b7cbf9a7a44acaff8d2a)]:
|
|
19
|
+
- @lynx-js/lynx-ui@3.136.0
|
|
20
|
+
- @lynx-js/luna-styles@0.2.2
|
|
21
|
+
|
|
3
22
|
## 0.0.15
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
@import "@lynx-js/luna-styles/index.css";
|
|
2
|
+
|
|
3
|
+
.demo-container {
|
|
4
|
+
width: 100%;
|
|
5
|
+
height: 100%;
|
|
6
|
+
padding: 36px 24px 24px;
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
align-items: center;
|
|
10
|
+
background-color: var(--canvas);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.header {
|
|
14
|
+
width: 100%;
|
|
15
|
+
margin-bottom: 20px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.title {
|
|
19
|
+
color: var(--content);
|
|
20
|
+
font-size: 28px;
|
|
21
|
+
font-weight: 700;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.description {
|
|
25
|
+
color: var(--content-subtle);
|
|
26
|
+
font-size: 14px;
|
|
27
|
+
margin-top: 6px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.metrics {
|
|
31
|
+
width: 100%;
|
|
32
|
+
margin-top: 14px;
|
|
33
|
+
padding: 12px;
|
|
34
|
+
display: flex;
|
|
35
|
+
flex-direction: row;
|
|
36
|
+
flex-wrap: wrap;
|
|
37
|
+
gap: 8px;
|
|
38
|
+
border-radius: 12px;
|
|
39
|
+
background-color: var(--paper);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.metric {
|
|
43
|
+
color: var(--content-subtle);
|
|
44
|
+
font-size: 12px;
|
|
45
|
+
padding: 6px 8px;
|
|
46
|
+
border-radius: 8px;
|
|
47
|
+
background-color: var(--canvas);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.metric--event {
|
|
51
|
+
color: var(--primary);
|
|
52
|
+
font-weight: 600;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.scroll-view {
|
|
56
|
+
background-color: var(--paper);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.scroll-content {
|
|
60
|
+
width: 100%;
|
|
61
|
+
padding: 14px;
|
|
62
|
+
display: flex;
|
|
63
|
+
flex-direction: column;
|
|
64
|
+
gap: 12px;
|
|
65
|
+
background: linear-gradient(
|
|
66
|
+
180deg,
|
|
67
|
+
var(--gradient-a),
|
|
68
|
+
var(--gradient-b),
|
|
69
|
+
var(--gradient-c),
|
|
70
|
+
var(--gradient-d)
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.card {
|
|
75
|
+
width: 100%;
|
|
76
|
+
height: 88px;
|
|
77
|
+
padding: 14px 18px;
|
|
78
|
+
display: flex;
|
|
79
|
+
flex-direction: row;
|
|
80
|
+
align-items: center;
|
|
81
|
+
border-radius: 16px;
|
|
82
|
+
background-color: var(--canvas);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.card__index {
|
|
86
|
+
width: 52px;
|
|
87
|
+
color: var(--primary);
|
|
88
|
+
font-size: 32px;
|
|
89
|
+
font-weight: 700;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.card__copy {
|
|
93
|
+
display: flex;
|
|
94
|
+
flex-direction: column;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.card__title {
|
|
98
|
+
color: var(--content);
|
|
99
|
+
font-size: 16px;
|
|
100
|
+
font-weight: 600;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.card__subtitle {
|
|
104
|
+
color: var(--content-subtle);
|
|
105
|
+
font-size: 12px;
|
|
106
|
+
margin-top: 4px;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.bounce-item {
|
|
110
|
+
width: 100%;
|
|
111
|
+
height: 96px;
|
|
112
|
+
display: flex;
|
|
113
|
+
flex-direction: column;
|
|
114
|
+
align-items: center;
|
|
115
|
+
justify-content: center;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.bounce-item--upper {
|
|
119
|
+
background-color: var(--primary);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.bounce-item--lower {
|
|
123
|
+
background-color: var(--primary-2);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.bounce-item__label {
|
|
127
|
+
color: var(--gradient-content);
|
|
128
|
+
font-size: 16px;
|
|
129
|
+
font-weight: 700;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.bounce-item__hint {
|
|
133
|
+
color: var(--gradient-content);
|
|
134
|
+
font-size: 12px;
|
|
135
|
+
margin-top: 4px;
|
|
136
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
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 { ScrollView } from '@lynx-js/lynx-ui'
|
|
8
|
+
import type { ScrollEvent } from '@lynx-js/types'
|
|
9
|
+
|
|
10
|
+
import './index.css'
|
|
11
|
+
|
|
12
|
+
const VIEWPORT_HEIGHT = 420
|
|
13
|
+
const TRIGGER_DISTANCE = 48
|
|
14
|
+
const ITEMS = Array.from({ length: 12 }, (_, index) => index + 1)
|
|
15
|
+
|
|
16
|
+
interface Metrics {
|
|
17
|
+
bounceCount: number
|
|
18
|
+
lastBounce: 'none' | 'upper' | 'lower'
|
|
19
|
+
maxLowerDistance: number
|
|
20
|
+
maxUpperDistance: number
|
|
21
|
+
minScrollTop: number
|
|
22
|
+
scrollHeight: number
|
|
23
|
+
scrollTop: number
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function BounceItem(props: {
|
|
27
|
+
direction: 'upper' | 'lower'
|
|
28
|
+
label: string
|
|
29
|
+
}) {
|
|
30
|
+
const { direction, label } = props
|
|
31
|
+
return (
|
|
32
|
+
<view className={`bounce-item bounce-item--${direction}`}>
|
|
33
|
+
<text className='bounce-item__label'>{label}</text>
|
|
34
|
+
<text className='bounce-item__hint'>Threshold: 48px</text>
|
|
35
|
+
</view>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function formatMetric(value: number) {
|
|
40
|
+
return Number.isFinite(value) ? value.toFixed(1) : '--'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function App() {
|
|
44
|
+
const [metrics, setMetrics] = useState<Metrics>({
|
|
45
|
+
bounceCount: 0,
|
|
46
|
+
lastBounce: 'none',
|
|
47
|
+
maxLowerDistance: 0,
|
|
48
|
+
maxUpperDistance: 0,
|
|
49
|
+
minScrollTop: 0,
|
|
50
|
+
scrollHeight: 0,
|
|
51
|
+
scrollTop: 0,
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const handleScroll = (event: ScrollEvent) => {
|
|
55
|
+
const { scrollHeight, scrollTop } = event.detail
|
|
56
|
+
const upperDistance = Math.max(0, -scrollTop)
|
|
57
|
+
const lowerDistance = Math.max(0, scrollTop - scrollHeight)
|
|
58
|
+
|
|
59
|
+
setMetrics(previous => ({
|
|
60
|
+
...previous,
|
|
61
|
+
maxLowerDistance: Math.max(
|
|
62
|
+
previous.maxLowerDistance,
|
|
63
|
+
lowerDistance,
|
|
64
|
+
),
|
|
65
|
+
maxUpperDistance: Math.max(
|
|
66
|
+
previous.maxUpperDistance,
|
|
67
|
+
upperDistance,
|
|
68
|
+
),
|
|
69
|
+
minScrollTop: Math.min(previous.minScrollTop, scrollTop),
|
|
70
|
+
scrollHeight,
|
|
71
|
+
scrollTop,
|
|
72
|
+
}))
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<view className='demo-container lunaris-dark'>
|
|
77
|
+
<view className='header'>
|
|
78
|
+
<text className='title'>Native useBounces</text>
|
|
79
|
+
<text className='description'>
|
|
80
|
+
Pull beyond both edges and watch bindscroll metrics.
|
|
81
|
+
</text>
|
|
82
|
+
<view className='metrics'>
|
|
83
|
+
<text className='metric'>
|
|
84
|
+
{`scrollTop: ${formatMetric(metrics.scrollTop)}`}
|
|
85
|
+
</text>
|
|
86
|
+
<text className='metric'>
|
|
87
|
+
{`min scrollTop: ${formatMetric(metrics.minScrollTop)}`}
|
|
88
|
+
</text>
|
|
89
|
+
<text className='metric'>
|
|
90
|
+
{`max upper: ${formatMetric(metrics.maxUpperDistance)}`}
|
|
91
|
+
</text>
|
|
92
|
+
<text className='metric'>
|
|
93
|
+
{`max lower: ${formatMetric(metrics.maxLowerDistance)}`}
|
|
94
|
+
</text>
|
|
95
|
+
<text className='metric'>
|
|
96
|
+
{`scrollHeight: ${formatMetric(metrics.scrollHeight)}`}
|
|
97
|
+
</text>
|
|
98
|
+
<text className='metric metric--event'>
|
|
99
|
+
{`bounce event: ${metrics.lastBounce} (${metrics.bounceCount})`}
|
|
100
|
+
</text>
|
|
101
|
+
</view>
|
|
102
|
+
</view>
|
|
103
|
+
|
|
104
|
+
<ScrollView
|
|
105
|
+
enableNewArch={true}
|
|
106
|
+
scrollOrientation='vertical'
|
|
107
|
+
className='scroll-view'
|
|
108
|
+
style={{
|
|
109
|
+
width: '100%',
|
|
110
|
+
height: `${VIEWPORT_HEIGHT}px`,
|
|
111
|
+
borderRadius: '20px',
|
|
112
|
+
}}
|
|
113
|
+
onScroll={handleScroll}
|
|
114
|
+
bounceableOptions={{
|
|
115
|
+
enableBounces: true,
|
|
116
|
+
alwaysBouncing: true,
|
|
117
|
+
singleSidedBounce: 'both',
|
|
118
|
+
startBounceTriggerDistance: TRIGGER_DISTANCE,
|
|
119
|
+
endBounceTriggerDistance: TRIGGER_DISTANCE,
|
|
120
|
+
upperBounceItem: (
|
|
121
|
+
<BounceItem direction='upper' label='Native upper bounce' />
|
|
122
|
+
),
|
|
123
|
+
lowerBounceItem: (
|
|
124
|
+
<BounceItem direction='lower' label='Native lower bounce' />
|
|
125
|
+
),
|
|
126
|
+
onScrollToBounces: ({ direction }) => {
|
|
127
|
+
setMetrics(previous => ({
|
|
128
|
+
...previous,
|
|
129
|
+
bounceCount: previous.bounceCount + 1,
|
|
130
|
+
lastBounce: direction,
|
|
131
|
+
}))
|
|
132
|
+
},
|
|
133
|
+
}}
|
|
134
|
+
>
|
|
135
|
+
<view className='scroll-content'>
|
|
136
|
+
{ITEMS.map(item => (
|
|
137
|
+
<view className='card' key={`native-bounce-card-${item}`}>
|
|
138
|
+
<text className='card__index'>{`${item}`}</text>
|
|
139
|
+
<view className='card__copy'>
|
|
140
|
+
<text className='card__title'>Native ScrollView</text>
|
|
141
|
+
<text className='card__subtitle'>
|
|
142
|
+
scroll-view-new-arch=true
|
|
143
|
+
</text>
|
|
144
|
+
</view>
|
|
145
|
+
</view>
|
|
146
|
+
))}
|
|
147
|
+
</view>
|
|
148
|
+
</ScrollView>
|
|
149
|
+
</view>
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
root.render(<App />)
|
|
154
|
+
|
|
155
|
+
export default App
|
package/ScrollBy/index.css
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
.demo-container {
|
|
4
4
|
width: 100%;
|
|
5
5
|
height: 100%;
|
|
6
|
-
padding:
|
|
6
|
+
padding: 64px 20px 32px;
|
|
7
7
|
background-color: var(--canvas);
|
|
8
8
|
}
|
|
9
9
|
|
|
@@ -17,26 +17,34 @@
|
|
|
17
17
|
|
|
18
18
|
.button {
|
|
19
19
|
flex: 1;
|
|
20
|
-
height:
|
|
21
|
-
border-radius:
|
|
20
|
+
height: 44px;
|
|
21
|
+
border-radius: 999px;
|
|
22
22
|
display: flex;
|
|
23
23
|
align-items: center;
|
|
24
24
|
justify-content: center;
|
|
25
|
-
background-color: var(--
|
|
25
|
+
background-color: var(--neutral);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.button.ui-active {
|
|
29
|
+
background-color: var(--neutral-2);
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
.button--primary {
|
|
29
|
-
background-color: var(--
|
|
33
|
+
background-color: var(--gradient-a);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.button--primary.ui-active {
|
|
37
|
+
background-color: var(--gradient-b);
|
|
30
38
|
}
|
|
31
39
|
|
|
32
40
|
.button-text {
|
|
33
|
-
color: var(--content);
|
|
34
|
-
font-size:
|
|
35
|
-
font-weight:
|
|
41
|
+
color: var(--neutral-content);
|
|
42
|
+
font-size: 14px;
|
|
43
|
+
font-weight: 700;
|
|
36
44
|
}
|
|
37
45
|
|
|
38
46
|
.button--primary .button-text {
|
|
39
|
-
color: var(--
|
|
47
|
+
color: var(--gradient-content);
|
|
40
48
|
}
|
|
41
49
|
|
|
42
50
|
.scroll-view {
|
|
@@ -66,13 +74,13 @@
|
|
|
66
74
|
}
|
|
67
75
|
|
|
68
76
|
.card-title {
|
|
69
|
-
color: var(--content);
|
|
77
|
+
color: var(--gradient-content);
|
|
70
78
|
font-size: 20px;
|
|
71
79
|
font-weight: 700;
|
|
72
80
|
}
|
|
73
81
|
|
|
74
82
|
.card-subtitle {
|
|
75
83
|
margin-top: 6px;
|
|
76
|
-
color: var(--content-
|
|
84
|
+
color: var(--gradient-content-faded);
|
|
77
85
|
font-size: 13px;
|
|
78
86
|
}
|