Fix dark theme handling scrolling to the top

This commit is contained in:
Simounet 2020-11-27 11:01:15 +01:00
parent 6a3140f2f7
commit 974ff07076
No known key found for this signature in database
GPG key ID: 77D3B7DC794EB770
3 changed files with 8 additions and 5 deletions

View file

@ -89,7 +89,8 @@ function darkTheme() {
preferedColorScheme.init(); preferedColorScheme.init();
const lightThemeButtons = document.querySelectorAll('.js-theme-toggle[data-theme="light"]'); const lightThemeButtons = document.querySelectorAll('.js-theme-toggle[data-theme="light"]');
[...lightThemeButtons].map((lightThemeButton) => { [...lightThemeButtons].map((lightThemeButton) => {
lightThemeButton.addEventListener('click', () => { lightThemeButton.addEventListener('click', (e) => {
e.preventDefault();
themeDom.removeClass(rootEl); themeDom.removeClass(rootEl);
themeCookie.setCookie(false); themeCookie.setCookie(false);
}); });
@ -97,7 +98,8 @@ function darkTheme() {
}); });
const darkThemeButtons = document.querySelectorAll('.js-theme-toggle[data-theme="dark"]'); const darkThemeButtons = document.querySelectorAll('.js-theme-toggle[data-theme="dark"]');
[...darkThemeButtons].map((darkThemeButton) => { [...darkThemeButtons].map((darkThemeButton) => {
darkThemeButton.addEventListener('click', () => { darkThemeButton.addEventListener('click', (e) => {
e.preventDefault();
themeDom.addClass(rootEl); themeDom.addClass(rootEl);
themeCookie.setCookie(true); themeCookie.setCookie(true);
}); });
@ -105,7 +107,8 @@ function darkTheme() {
}); });
const autoThemeButtons = document.querySelectorAll('.js-theme-toggle[data-theme="auto"]'); const autoThemeButtons = document.querySelectorAll('.js-theme-toggle[data-theme="auto"]');
[...autoThemeButtons].map((autoThemeButton) => { [...autoThemeButtons].map((autoThemeButton) => {
autoThemeButton.addEventListener('click', () => { autoThemeButton.addEventListener('click', (e) => {
e.preventDefault();
themeCookie.removeCookie(); themeCookie.removeCookie();
preferedColorScheme.choose(); preferedColorScheme.choose();
}); });

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long