Use Math.ceil instead of round

master
Vitaliy Filippov 2020-04-27 22:04:59 +03:00
parent 8dd3bb5b93
commit 691b6384ee
2 changed files with 2 additions and 4 deletions

View File

@ -181,7 +181,7 @@ export default class Picker extends React.Component
+ (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop)
- (document.documentElement.clientTop || document.body.clientTop || 0);
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);
let left = (clientRect.left
+ (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;
}
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 };
}
}

View File

@ -87,7 +87,6 @@ class Test extends React.PureComponent
/>
<PickerMenu
autoHide={true}
minWidth={200}
renderInput={p => <button
{...p}
focused={undefined}
@ -104,7 +103,6 @@ class Test extends React.PureComponent
{this.state.ctx_x != null
? <PickerMenu
autoHide={true}
minWidth={200}
items={NAMES}
popupX={this.state.ctx_x}
popupY={this.state.ctx_y}