Use Math.ceil instead of round
parent
8dd3bb5b93
commit
691b6384ee
|
@ -181,7 +181,7 @@ export default class Picker extends React.Component
|
||||||
+ (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop)
|
+ (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop)
|
||||||
- (document.documentElement.clientTop || document.body.clientTop || 0);
|
- (document.documentElement.clientTop || document.body.clientTop || 0);
|
||||||
const max_height = (direction == 'down' ? screen_height-top-(clientRect.height||0)-32 : top-32);
|
const max_height = (direction == 'down' ? screen_height-top-(clientRect.height||0)-32 : top-32);
|
||||||
const height = Math.round(popup_size.height < max_height ? popup_size.height : max_height);
|
const height = Math.ceil(popup_size.height < max_height ? popup_size.height : max_height);
|
||||||
top = direction == 'down' ? (top + (clientRect.height||0)) : (top - height);
|
top = direction == 'down' ? (top + (clientRect.height||0)) : (top - height);
|
||||||
let left = (clientRect.left
|
let left = (clientRect.left
|
||||||
+ (window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft)
|
+ (window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft)
|
||||||
|
@ -191,7 +191,7 @@ export default class Picker extends React.Component
|
||||||
left = screen_width - popup_size.width;
|
left = screen_width - popup_size.width;
|
||||||
}
|
}
|
||||||
let width = (clientRect.width||0) > popup_size.width ? clientRect.width : popup_size.width;
|
let width = (clientRect.width||0) > popup_size.width ? clientRect.width : popup_size.width;
|
||||||
width = Math.round(props && props.minWidth && width < props.minWidth ? props.minWidth : width);
|
width = Math.ceil(props && props.minWidth && width < props.minWidth ? props.minWidth : width);
|
||||||
return { top, left, width, height };
|
return { top, left, width, height };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
main.js
2
main.js
|
@ -87,7 +87,6 @@ class Test extends React.PureComponent
|
||||||
/>
|
/>
|
||||||
<PickerMenu
|
<PickerMenu
|
||||||
autoHide={true}
|
autoHide={true}
|
||||||
minWidth={200}
|
|
||||||
renderInput={p => <button
|
renderInput={p => <button
|
||||||
{...p}
|
{...p}
|
||||||
focused={undefined}
|
focused={undefined}
|
||||||
|
@ -104,7 +103,6 @@ class Test extends React.PureComponent
|
||||||
{this.state.ctx_x != null
|
{this.state.ctx_x != null
|
||||||
? <PickerMenu
|
? <PickerMenu
|
||||||
autoHide={true}
|
autoHide={true}
|
||||||
minWidth={200}
|
|
||||||
items={NAMES}
|
items={NAMES}
|
||||||
popupX={this.state.ctx_x}
|
popupX={this.state.ctx_x}
|
||||||
popupY={this.state.ctx_y}
|
popupY={this.state.ctx_y}
|
||||||
|
|
Loading…
Reference in New Issue