Open DimaGashko opened 4 years ago
Ok, I don't like that function at all. Too complicated to do so simple thing. I would write so (
/** @param {'enable'|'disable'} value */
scrollBehaviour(value) {
if (!this.config.disableScroll) return
if (value === 'enable') {
document.body.style.overflow = '';
} else if (value === 'disable') {
document.body.style.overflow = 'hidden';
}
}
Or:
/** @param {'enable'|'disable'} value */
scrollBehaviour(value) {
if (!this.config.disableScroll) return
const overflow = (value === 'disable') ? 'hidden' : '';
document.body.style.overflow = overflow;
}
Or:
/** @param {boolean} value */
function toggleScrolling(value) {
if (!this.config.disableScroll) return
document.body.style.overflow = (!value) ? 'hidden' : '';
}
I've just found one line in the source code that made me confused
https://github.com/ghosh/Micromodal/blob/master/lib/src/index.js#L106
Why would you use querySelector to find the body element? There's
document.body
to do this - shorter, faster, full support