Last active
November 14, 2018 12:14
-
-
Save olecksamdr/9700a1784efbdd2a867414a83b28ad5d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
componentDidUpdate(prevProps, prevState) { | |
if (isBrowser()) { | |
const { open, bodyAlign } = this.state; | |
if (prevState.open !== open) { | |
const { right } = this.body.current.getBoundingClientRect(); | |
if (right > Root.innerWidth && bodyAlign === 'left') { | |
// Do not go beyond the right window border | |
this.setState({ bodyAlign: 'right' }); | |
} else if (right <= Root.innerWidth && bodyAlign === 'right') { | |
this.setState({ bodyAlign: 'left' }); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment