UNPKG

generator-bingo-dig-h5

Version:

Bingo-dig-h5 generator by BINGO.DIG

60 lines (45 loc) 1.26 kB
var React = require('react'); var Classable = require('../mixins/classable'); var Overlay = React.createClass({ mixins: [Classable], propTypes: { show: React.PropTypes.bool, autoLockScrolling: React.PropTypes.bool }, getDefaultProps: function() { return { autoLockScrolling: true }; }, componentDidUpdate: function(prevProps, prevState) { if (this.props.autoLockScrolling) (this.props.show) ? this._preventScrolling() : this._allowScrolling(); }, render: function() { var { className, ...other } = this.props; var classes = this.getClasses('dig-overlay', { 'dig-is-shown': this.props.show }); return ( <div {...other} className={classes} /> ); }, preventScrolling: function() { if (!this.props.autoLockScrolling) this._preventScrolling(); }, allowScrolling: function() { if (!this.props.autoLockScrolling) this._allowScrolling(); }, _preventScrolling: function() { var body = document.getElementsByTagName('body')[0]; body.style.overflow = 'hidden'; }, _allowScrolling: function() { var body = document.getElementsByTagName('body')[0]; body.style.overflow = ''; } }); module.exports = Overlay;