ouibounce
ouibounce copied to clipboard
Dynamic checking based on DOM attribute
It would be really handy to be able to enable/disable dynamically whether a modal should be opened without having to use the ouibounce API and/or disabling it permanently through the cookie.
This is my current local patch but I'm not sure this is the best approach:
function handleMouseleave(e) {
if (e.clientY > sensitivity || (checkCookieValue(cookieName, 'true') && !aggressive)) return;
_delayTimer = setTimeout(_fireAndCallback, delay);
}
is changed to:
function handleMouseleave(e) {
if (e.clientY > sensitivity || (checkCookieValue(cookieName, 'true') && !aggressive)) return;
if (el && el.getAttribute('data-ouibounce-disabled') === "true") return;
_delayTimer = setTimeout(_fireAndCallback, delay);
}
This way when the modal element has the data attribute "data-ouibounce-disabled" set to "true" the modal won't popup.