Skip to content

Instantly share code, notes, and snippets.

@laurisstepanovs
Last active January 23, 2024 23:33
Show Gist options
  • Save laurisstepanovs/0122244089f13eb7a6adad3e959b5b75 to your computer and use it in GitHub Desktop.
Save laurisstepanovs/0122244089f13eb7a6adad3e959b5b75 to your computer and use it in GitHub Desktop.
const splashScreenState = (mode:boolean) => {
const splashScreen = document.getElementById('splash-screen');
if(mode){
document.body.classList.add('page-loading')
splashScreen?.style.setProperty('display', 'flex')
} else {
document.body.classList.remove('page-loading')
splashScreen?.style.setProperty('display', 'none')
}
}
const setRtlMode = () => {
splashScreenState(true);
var link = document.getElementById("main-css");
if(link){
link.setAttribute("href", link.getAttribute("href")!.replace("style.bundle.css", "style.bundle.rtl.css"));
document.documentElement.setAttribute("dir", "rtl");
document.documentElement.setAttribute("direction", "rtl");
document.documentElement.setAttribute("style", "direction:rtl");
setTimeout(() => {
splashScreenState(false);
}, 1000);
}
};
const setLtrMode = () => {
splashScreenState(true);
var link = document.getElementById("main-css");
if(link){
document.documentElement.removeAttribute("dir");
document.documentElement.removeAttribute("direction");
document.documentElement.removeAttribute("style");
link.setAttribute("href", link.getAttribute("href")!.replace("style.bundle.rtl.css", "style.bundle.css"));
setTimeout(() => {
splashScreenState(false);
}, 1000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment