Maybe I will try to add a temporary variable.
let overlayEnabled = true;
function sizer(sz) {
// a bunch of CSS to resize my content
overlayEnabled = sz !== 'big';
}
$( "article" ).on("click", function(){
if (!overlayEnabled) {
return;
}
// build the contents of the overlay on-the-fly for this article
var aside = $(this).find("aside");
var o = $("#overlay");
o.contents().remove(); //destroy old content
o.append(aside[0].innerHTML); // add new content
o.css("display","block");
});
or if you don't want a flag variable, you can set data attribute on the overlay.
function sizer(sz) {
// a bunch of CSS to resize my content
$("#overlay").attr('data-enabled', sz !== 'big')
}
$( "article" ).on("click", function(){
const enabled = $("#overlay").attr('data-enabled');
// notice: the type of enabled is string
if (enabled === 'false') {
return;
}
// rest of code
})