Last active
March 22, 2019 10:19
-
-
Save rvanzon/0210cd5f9199b9a4346df68a7d4862e5 to your computer and use it in GitHub Desktop.
Framework 7 backdrop remover and reopener when used with hot reload (HRM)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function ($f7, reopenPopup = true) { | |
if (module.hot) { | |
module.hot.addStatusHandler(status => { | |
if (status === 'idle') { | |
const activePopup = document.querySelector('.modal-in') | |
// next tick | |
setTimeout(() => { | |
// remove all popup backdrops if all popups are closed | |
if (!document.querySelectorAll('.modal-in').length) { | |
const popupBackdrop = document.querySelector('.popup-backdrop') | |
if (popupBackdrop) { | |
popupBackdrop.classList.remove('backdrop-in') | |
} | |
if (reopenPopup && activePopup && activePopup.id) { | |
$f7.popup.open(`#${activePopup.id}`, false) | |
} | |
} | |
}, 0) | |
} | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
usage:
with Framework7 Vue
with vanilla js (not tested):