mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-23 18:17:38 +00:00
Attempt to prevent scroll on ios when overlay is open
This commit is contained in:
parent
9d470c4368
commit
dea08a474e
1 changed files with 7 additions and 0 deletions
|
|
@ -10,12 +10,14 @@ class Overlay extends React.Component {
|
|||
this._node.classList.add("overlay");
|
||||
this._handleKeyDown = this._handleKeyDown.bind(this);
|
||||
this._handleClick = this._handleClick.bind(this);
|
||||
this._handleTouchMove = this._handleTouchMove.bind(this);
|
||||
|
||||
window.document.body.appendChild(this._node);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
window.document.addEventListener("keydown", this._handleKeyDown);
|
||||
window.document.addEventListener("touchmove", this._handleTouchMove);
|
||||
// TODO: This is technically a race condition, since we could unmount before this fires.
|
||||
if (this.props.shouldAnimate) {
|
||||
setTimeout(() => {
|
||||
|
|
@ -31,9 +33,14 @@ class Overlay extends React.Component {
|
|||
componentWillUnmount() {
|
||||
window.document.body.removeChild(this._node);
|
||||
window.document.removeEventListener("keydown", this._handleKeyDown);
|
||||
window.document.removeEventListener("touchmove", this._handleTouchMove);
|
||||
document.body.classList.remove("overlay-open");
|
||||
}
|
||||
|
||||
_handleTouchMove(e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
_handleKeyDown(e) {
|
||||
// Esc
|
||||
if (e.keyCode === 27) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue