old
Maxim Komlev 2016-10-18 14:46:56 -07:00
parent eefa426960
commit 0e5b0530d4
2 changed files with 22 additions and 24 deletions

View File

@ -8,14 +8,14 @@
position: relative;
> input {
position: absolute;
z-index: 0;
width: 0.1px;
height: 0.1px;
padding: 0;
margin: 0;
overflow: hidden;
width: 0.1px !important;
height: 0.1px !important;
opacity: 0;
overflow: hidden;
position: absolute;
z-index: 0 !important;
padding: 0 !important;
margin: 0 !important;
}
}

View File

@ -37,28 +37,16 @@ var Overlay = function (_Component) {
_inherits(Overlay, _Component);
function Overlay() {
var _ref;
var _temp, _this, _ret;
_classCallCheck(this, Overlay);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Overlay.__proto__ || Object.getPrototypeOf(Overlay)).call.apply(_ref, [this].concat(args))), _this), _this.handleEscKey = function (e) {
if (_this.props.active && _this.props.onEscKeyDown && e.which === 27) {
_this.props.onEscKeyDown(e);
}
}, _temp), _possibleConstructorReturn(_this, _ret);
return _possibleConstructorReturn(this, (Overlay.__proto__ || Object.getPrototypeOf(Overlay)).apply(this, arguments));
}
_createClass(Overlay, [{
key: 'componentDidMount',
value: function componentDidMount() {
if (this.props.active) {
document.body.addEventListener('keydown', this.handleEscKey);
this.escKeyListener = document.body.addEventListener('keydown', this.handleEscKey.bind(this));
document.body.style.overflow = 'hidden';
}
}
@ -71,15 +59,25 @@ var Overlay = function (_Component) {
}, {
key: 'componentDidUpdate',
value: function componentDidUpdate() {
if (this.props.active) {
document.body.addEventListener('keydown', this.handleEscKey);
if (this.props.active && !this.escKeyListener) {
this.escKeyListener = document.body.addEventListener('keydown', this.handleEscKey.bind(this));
}
}
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
if (!document.querySelectorAll('[data-react-toolbox="overlay"]')[1]) document.body.style.overflow = '';
document.body.removeEventListener('keydown', this.handleEscKey);
if (this.escKeyListener) {
document.body.removeEventListener('keydown', this.handleEscKey);
this.escKeyListener = null;
}
}
}, {
key: 'handleEscKey',
value: function handleEscKey(e) {
if (this.props.active && this.props.onEscKeyDown && e.which === 27) {
this.props.onEscKeyDown(e);
}
}
}, {
key: 'render',