Port over FF handling of scrollbar offset

This commit is contained in:
Eric Bailey
2024-12-02 18:19:42 -06:00
parent 2e32d1dad6
commit e5470f946f
2 changed files with 10 additions and 4 deletions
+5 -2
View File
@@ -93,8 +93,11 @@
var htmlWidth = html.getBoundingClientRect().width; var htmlWidth = html.getBoundingClientRect().width;
var scrollbarWidth = (windowWidth - htmlWidth) / 2; var scrollbarWidth = (windowWidth - htmlWidth) / 2;
var scrollbarOffset = scrollbarWidth / 2; var scrollbarOffset = scrollbarWidth / 2;
html.style.setProperty('--scrollbar-offset', `${scrollbarOffset}px`); var isFF = /firefox/i.test(navigator.userAgent)
html.style.setProperty('--scrollbar-offset-negative', `-${scrollbarOffset}px`); if (!isFF) {
html.style.setProperty('--scrollbar-offset', `${scrollbarOffset}px`);
html.style.setProperty('--scrollbar-offset-negative', `-${scrollbarOffset}px`);
}
} catch (error) {} } catch (error) {}
</script> </script>
+5 -2
View File
@@ -98,8 +98,11 @@
var htmlWidth = html.getBoundingClientRect().width; var htmlWidth = html.getBoundingClientRect().width;
var scrollbarWidth = (windowWidth - htmlWidth) / 2; var scrollbarWidth = (windowWidth - htmlWidth) / 2;
var scrollbarOffset = scrollbarWidth / 2; var scrollbarOffset = scrollbarWidth / 2;
html.style.setProperty('--scrollbar-offset', `${scrollbarOffset}px`); var isFF = /firefox/i.test(navigator.userAgent)
html.style.setProperty('--scrollbar-offset-negative', `-${scrollbarOffset}px`); if (!isFF) {
html.style.setProperty('--scrollbar-offset', `${scrollbarOffset}px`);
html.style.setProperty('--scrollbar-offset-negative', `-${scrollbarOffset}px`);
}
} catch (error) {} } catch (error) {}
</script> </script>
</head> </head>