From dea08a474e1ab1e72758b7df6efd66ad69b722a7 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Sun, 23 Dec 2018 15:07:20 -0800 Subject: [PATCH] Attempt to prevent scroll on ios when overlay is open --- src/Overlay.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Overlay.js b/src/Overlay.js index afcb49e3..3dc8e030 100644 --- a/src/Overlay.js +++ b/src/Overlay.js @@ -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) {