Files
legolog/client/public/helpers.mjs
Ben 3f88e4435a search box and also search bar and also basket
Former-commit-id: d63b7aa5fe3ff0ac16d8f8eab2bb67724cf2ff56
2022-03-31 18:22:52 +01:00

24 lines
755 B
JavaScript

export function SwapActivePage(current, target) {
const currentPage = document.querySelector(`#${current}`);
const targetPage = document.querySelector(`#${target}`);
// TODO: Maybe we should use browser history instead of this?
// TODO: Maybe we should use a transition instead of this?
// transition
currentPage.classList.add('slide-out-left');
targetPage.classList.add('slide-in-left');
currentPage.classList.remove('slide-out-left');
targetPage.classList.remove('slide-in-left');
currentPage.style.display = 'none';
targetPage.style.display = 'block';
// wait for transition to finish
return new Promise((resolve) => {
setTimeout(() => {
resolve();
}, 500);
});
}