settings: Add animations switch

This commit is contained in:
Daniel 2023-05-09 22:20:11 +02:00
parent cec930beaf
commit a8e1c25394
5 changed files with 29 additions and 0 deletions

View File

@ -8,6 +8,7 @@
"dark_mode": false, "dark_mode": false,
"open_new_tab": false, "open_new_tab": false,
"blur": true, "blur": true,
"animations": true,
"hosted_by": "somebody" "hosted_by": "somebody"
}, },
"services": [ "services": [

View File

@ -30,6 +30,9 @@ body {
.noblur { .noblur {
--blur: blur(0); --blur: blur(0);
} }
.noanim * {
transition: none !important;
}
::-webkit-scrollbar { ::-webkit-scrollbar {
display: none; display: none;

View File

@ -114,6 +114,14 @@
</div> </div>
<div class="switch"></div> <div class="switch"></div>
</div> </div>
<div class="setting" onclick="animations()" id="setting-animations">
<div class="icon">animation</div>
<div class="text">
<div class="name">Animations</div>
<div class="desc">Show nice and fancy page transitions, improves experience</div>
</div>
<div class="switch"></div>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -89,6 +89,7 @@ function load_config(conf) {
switch_theme(get_bool("dark_mode")); switch_theme(get_bool("dark_mode"));
new_tab_toggle(get_bool("open_new_tab")); new_tab_toggle(get_bool("open_new_tab"));
blur_toggle(get_bool("blur")); blur_toggle(get_bool("blur"));
animations(get_bool("animations"));
} }
function is_secure(uri) { function is_secure(uri) {

View File

@ -92,6 +92,22 @@ function blur_toggle(value) {
} }
} }
function animations(value) {
let v = get_bool("animations");
if (value === undefined) v = !v;
config("animations", v);
setting = get("setting-animations").classList;
let body = document.body.classList;
if (v) {
setting.add("checked");
body.remove("noanim");
}
else {
setting.remove("checked");
body.add("noanim");
}
}
function reset_all_settings() { function reset_all_settings() {
if (check_cookies()) localStorage.clear(); if (check_cookies()) localStorage.clear();
load_config(CONFIG_DEFAULT); load_config(CONFIG_DEFAULT);