Skip to content

Commit e697a71

Browse files
authored
Add sidebar gradient state handling script
1 parent 4c71ccd commit e697a71

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

web/index.html

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,46 @@ <h1 class="title">ProStore Installer</h1><br>
3333
pulse('reset');
3434
loadingImg(0);
3535
</script>
36+
<script>
37+
(function() {
38+
// run only if the elements exist
39+
const container = document.querySelector('.sidebar-container');
40+
const sidebar = container?.querySelector('.sidebar');
41+
42+
if (!container || !sidebar) return;
43+
44+
// tiny threshold to avoid fractional-pixel issues
45+
const THRESH = 1;
46+
47+
function updateGradientState() {
48+
// if no horizontal overflow, mark no-overflow
49+
if (sidebar.scrollWidth <= sidebar.clientWidth + THRESH) {
50+
container.classList.add('no-overflow');
51+
container.classList.remove('scrolled-end');
52+
return;
53+
} else {
54+
container.classList.remove('no-overflow');
55+
}
56+
57+
// if scrolled to the far right, hide gradient
58+
if (sidebar.scrollLeft + sidebar.clientWidth >= sidebar.scrollWidth - THRESH) {
59+
container.classList.add('scrolled-end');
60+
} else {
61+
container.classList.remove('scrolled-end');
62+
}
63+
}
64+
65+
// listen to scroll + resize + orientation changes
66+
sidebar.addEventListener('scroll', updateGradientState, { passive: true });
67+
window.addEventListener('resize', updateGradientState);
68+
window.addEventListener('orientationchange', updateGradientState);
69+
70+
// run initial check once DOM is ready
71+
document.addEventListener('DOMContentLoaded', updateGradientState);
72+
// also run immediately in case script is after DOM
73+
updateGradientState();
74+
})();
75+
</script>
76+
3677
</body>
3778
</html>

0 commit comments

Comments
 (0)