Skip to content

Commit 0d1265e

Browse files
committed
Adapt pickers to calculate position with scroll
1 parent c3ef6bd commit 0d1265e

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

components/time_picker/Clock.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class Clock extends React.Component {
5454
handleCalculateShape = () => {
5555
const { top, left, width } = this.refs.placeholder.getBoundingClientRect();
5656
this.setState({
57-
center: { x: left + width / 2, y: top + width / 2 },
57+
center: { x: left + width / 2 - window.scrollX, y: top + width / 2 - window.scrollX },
5858
radius: width / 2
5959
});
6060
};

components/time_picker/TimePickerDialog.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class TimePickerDialog extends React.Component {
2626
displayTime: this.props.value
2727
};
2828

29-
componentWillUpdate (nextProps) {
30-
if (!this.props.active && nextProps.active) {
29+
componentDidUpdate (prevProps) {
30+
if (!prevProps.active && this.props.active) {
3131
setTimeout(this.refs.clock.handleCalculateShape, 1000);
3232
}
3333
}

components/utils/events.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
export default {
22
getMousePosition (event) {
33
return {
4-
x: event.pageX,
5-
y: event.pageY
4+
x: event.pageX - window.scrollX,
5+
y: event.pageY - window.scrollY
66
};
77
},
88

99
getTouchPosition (event) {
1010
return {
11-
x: event.touches[0].pageX,
12-
y: event.touches[0].pageY
11+
x: event.touches[0].pageX - window.scrollX,
12+
y: event.touches[0].pageY - window.scrollY
1313
};
1414
},
1515

1616
pauseEvent (event) {
1717
event.stopPropagation();
1818
event.preventDefault();
19-
event.returnValue = false;
20-
event.cancelBubble = true;
2119
},
2220

2321
addEventsToDocument (eventMap) {

0 commit comments

Comments
 (0)