mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2025-01-28 02:57:58 +01:00
Added MAX_HEIGHT constant.
This commit is contained in:
parent
e11a5a823a
commit
33fdc52667
1 changed files with 7 additions and 3 deletions
|
@ -4,6 +4,8 @@ import classnames from 'classnames'
|
|||
import Autocomplete from 'react-autocomplete'
|
||||
|
||||
|
||||
const MAX_HEIGHT = 140;
|
||||
|
||||
class AutocompleteMenu extends React.Component {
|
||||
static propTypes = {
|
||||
keepMenuWithinWindowBounds: PropTypes.bool,
|
||||
|
@ -14,9 +16,11 @@ class AutocompleteMenu extends React.Component {
|
|||
calcMaxHeight() {
|
||||
if(this.props.keepMenuWithinWindowBounds) {
|
||||
const maxHeight = window.innerHeight - this.autocompleteMenuEl.getBoundingClientRect().top;
|
||||
if(maxHeight != this.state.maxHeight) {
|
||||
const limitedMaxHeight = Math.min(maxHeight, MAX_HEIGHT);
|
||||
|
||||
if(limitedMaxHeight != this.state.maxHeight) {
|
||||
this.setState({
|
||||
maxHeight: maxHeight
|
||||
maxHeight: limitedMaxHeight
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +36,7 @@ class AutocompleteMenu extends React.Component {
|
|||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
maxHeight: 90
|
||||
maxHeight: MAX_HEIGHT
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue