Skip to content

Commit 31f3af9

Browse files
fix(range): 组件位置计算问题 close #969 (#970)
* fix(range): 组件位置计算问题 #969 * refactor(range): 去除isForceUpdatePos字段,componentWillReceiveProps时都会重新计算位置 Co-authored-by: Garfield Lee <[email protected]>
1 parent abb90cd commit 31f3af9

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/components/range/index.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,17 @@ export default class AtRange extends AtComponent<AtRangeProps, AtRangeState> {
9999
}
100100
}
101101

102+
private updatePos(): void {
103+
delayQuerySelector(this, '.at-range__container', 0)
104+
.then(rect => {
105+
this.width = Math.round(rect[0].width)
106+
this.left = Math.round(rect[0].left)
107+
})
108+
}
109+
102110
public componentWillReceiveProps(nextProps: AtRangeProps): void {
103111
const { value } = nextProps
112+
this.updatePos()
104113
if (
105114
this.props.value![0] !== value![0] ||
106115
this.props.value![1] !== value![1]
@@ -111,13 +120,8 @@ export default class AtRange extends AtComponent<AtRangeProps, AtRangeState> {
111120

112121
public componentDidMount(): void {
113122
const { value } = this.props
114-
delayQuerySelector(this, '.at-range__container', 0).then(rect => {
115-
this.width = Math.round(rect[0].width)
116-
this.left = Math.round(rect[0].left)
117-
this.setValue(value!)
118-
})
119-
// this.triggerEvent('onChange')
120-
// this.triggerEvent('onAfterChange')
123+
this.updatePos()
124+
this.setValue(value!)
121125
}
122126

123127
public render(): JSX.Element {

0 commit comments

Comments
 (0)