Skip to content

Commit

Permalink
fix: 修复视窗滚动导致的偏差
Browse files Browse the repository at this point in the history
  • Loading branch information
ShanaMaid committed Oct 30, 2018
1 parent 188d13f commit 56f1d08
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions components/TimePicker/TimePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,12 @@ export class TimePicker extends Component<ITimePickerProps, ITimePickerState> {
return;
}
const rect = this.refTimePickerConatainer.getBoundingClientRect();
const pageY = window.pageYOffset; // 当前滚动条y轴偏移量
const pageX = window.pageXOffset; // 当前滚动条x轴偏移量
this.setState({
panelPos: {
left: rect.left,
top: rect.top,
left: rect.left + pageX,
top: rect.top + pageY,
}
});
}
Expand Down

0 comments on commit 56f1d08

Please sign in to comment.