Chapter width setting adds utility classes to main

This commit is contained in:
Tetrakern 2023-02-04 16:26:54 +01:00
parent 7352ecd5c3
commit ab117a5c6d
2 changed files with 11 additions and 2 deletions

2
js/chapter.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -875,6 +875,9 @@ const /** @const {HTMLInputElement} */ fcn_siteWidthText = _$$$('reader-settings
*/
function fcn_updateSiteWidth(value, save = true) {
// Target
let main = _$('main');
// Evaluate
value = fcn_clamp(640, 1920, value ?? 960);
@ -884,7 +887,13 @@ function fcn_updateSiteWidth(value, save = true) {
fcn_siteWidthReset.classList.toggle('_modified', value != fcn_siteWidthDefault);
// Update site-width property
_$('main').style.setProperty('--site-width', `${value}px`);
main.style.setProperty('--site-width', `${value}px`);
// Toggle utility classes
main.classList.toggle('_default-width', value == fcn_theRoot.dataset.siteWidthDefault);
main.classList.toggle('_below-1024', value < 1024 && value >= 768);
main.classList.toggle('_below-768', value < 768 && value > 640);
main.classList.toggle('_640-and-below', value <= 640);
// Update local storage
fcn_formatting['site-width'] = value;