@gm-mobile/react 1.1.7-beta.3 → 1.1.8-beta.0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gm-mobile/react",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8-beta.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "liyatang <liyatang@qq.com>",
|
|
6
6
|
"homepage": "https://github.com/gmfe/gm-mobile#readme",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@gm-common/number": "^2.2.9",
|
|
29
29
|
"@gm-common/tool": "^2.2.9",
|
|
30
|
-
"@gm-mobile/locales": "^1.1.
|
|
30
|
+
"@gm-mobile/locales": "^1.1.8-beta.0",
|
|
31
31
|
"classnames": "^2.2.6"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "c57de4f19f88ac2c1e89d07b3dc418756a8b1978"
|
|
34
34
|
}
|
|
@@ -12,22 +12,21 @@ class PickerColumn extends React.Component {
|
|
|
12
12
|
startScrollerTranslate: 0,
|
|
13
13
|
...this.computeTranslate(props),
|
|
14
14
|
}
|
|
15
|
-
this.divRef = React.createRef()
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
componentDidMount() {
|
|
18
|
+
ReactDOM.findDOMNode(this.refScroll).addEventListener(
|
|
19
|
+
'touchmove',
|
|
20
|
+
this.handleTouchMove
|
|
21
|
+
)
|
|
22
|
+
}
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
componentWillUnmount() {
|
|
25
|
+
ReactDOM.findDOMNode(this.refScroll).removeEventListener(
|
|
26
|
+
'touchmove',
|
|
27
|
+
this.handleTouchMove
|
|
28
|
+
)
|
|
29
|
+
}
|
|
31
30
|
|
|
32
31
|
componentWillReceiveProps(nextProps) {
|
|
33
32
|
if (this.state.isMoving) {
|
|
@@ -37,7 +36,7 @@ class PickerColumn extends React.Component {
|
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
computeTranslate = (props) => {
|
|
40
|
-
const { options, value, columnHeight } = props
|
|
39
|
+
const { options, value, itemHeight, columnHeight } = props
|
|
41
40
|
let selectedIndex = _.findIndex(options, (option) => option.value === value)
|
|
42
41
|
if (selectedIndex < 0) {
|
|
43
42
|
// throw new ReferenceError();
|
|
@@ -51,16 +50,10 @@ class PickerColumn extends React.Component {
|
|
|
51
50
|
this.handleOptionSelected(options[0])
|
|
52
51
|
selectedIndex = 0
|
|
53
52
|
}
|
|
54
|
-
|
|
55
|
-
const itemHeight =
|
|
56
|
-
this.divRef?.current?.childNodes?.[selectedIndex]?.clientHeight ?? 40
|
|
57
|
-
let addHeight = 40
|
|
58
|
-
// 计算translate3d要移动的距离
|
|
59
|
-
for (let i = 0; i < selectedIndex; i++) {
|
|
60
|
-
addHeight += this.divRef?.current?.childNodes?.[i]?.clientHeight ?? 40
|
|
61
|
-
}
|
|
53
|
+
|
|
62
54
|
return {
|
|
63
|
-
scrollerTranslate:
|
|
55
|
+
scrollerTranslate:
|
|
56
|
+
columnHeight / 2 - itemHeight / 2 - selectedIndex * itemHeight,
|
|
64
57
|
minTranslate:
|
|
65
58
|
columnHeight / 2 - itemHeight * options.length + itemHeight / 2,
|
|
66
59
|
maxTranslate: columnHeight / 2 - itemHeight / 2,
|
|
@@ -160,17 +153,11 @@ class PickerColumn extends React.Component {
|
|
|
160
153
|
const { options, renderOption, itemHeight, value } = this.props
|
|
161
154
|
return options.map((option, index) => {
|
|
162
155
|
const style = {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
// lineHeight: itemHeight + 'px',
|
|
166
|
-
display: 'flex',
|
|
167
|
-
justifyContent: 'center',
|
|
168
|
-
alignItems: 'center',
|
|
156
|
+
height: itemHeight + 'px',
|
|
157
|
+
lineHeight: itemHeight + 'px',
|
|
169
158
|
}
|
|
170
159
|
const className = `m-picker-item${
|
|
171
|
-
option.value === value
|
|
172
|
-
? ' m-picker-highlight m-picker-item-selected m-border-1px-top-before m-border-1px-bottom-after'
|
|
173
|
-
: ''
|
|
160
|
+
option.value === value ? ' m-picker-item-selected' : ''
|
|
174
161
|
}`
|
|
175
162
|
return (
|
|
176
163
|
<div
|
|
@@ -200,8 +187,7 @@ class PickerColumn extends React.Component {
|
|
|
200
187
|
return (
|
|
201
188
|
<div className='m-picker-column'>
|
|
202
189
|
<div
|
|
203
|
-
|
|
204
|
-
ref={this.divRef}
|
|
190
|
+
ref={(ref) => (this.refScroll = ref)}
|
|
205
191
|
className='m-picker-scroll'
|
|
206
192
|
style={style}
|
|
207
193
|
onTouchStart={this.handleTouchStart}
|
|
@@ -24,16 +24,17 @@
|
|
|
24
24
|
justify-content: center;
|
|
25
25
|
height: 100%;
|
|
26
26
|
padding: 0 12px;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
// 影响大屏ios的效果
|
|
28
|
+
// -webkit-mask-box-image:
|
|
29
|
+
// linear-gradient(
|
|
30
|
+
// to top,
|
|
31
|
+
// transparent,
|
|
32
|
+
// transparent 5%,
|
|
33
|
+
// white 20%,
|
|
34
|
+
// white 80%,
|
|
35
|
+
// transparent 95%,
|
|
36
|
+
// transparent
|
|
37
|
+
// );
|
|
37
38
|
|
|
38
39
|
.m-picker-column {
|
|
39
40
|
flex: 1 1;
|
|
@@ -50,10 +51,10 @@
|
|
|
50
51
|
.m-picker-item {
|
|
51
52
|
position: relative;
|
|
52
53
|
padding: 0 4px;
|
|
53
|
-
|
|
54
|
+
white-space: nowrap;
|
|
54
55
|
color: var(--m-color-desc);
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
overflow: hidden;
|
|
57
|
+
text-overflow: ellipsis;
|
|
57
58
|
cursor: pointer;
|
|
58
59
|
|
|
59
60
|
&.m-picker-item-selected {
|