diff options
| author | altaf-creator <dev@altafcreator.com> | 2026-04-30 22:01:53 +0800 |
|---|---|---|
| committer | altaf-creator <dev@altafcreator.com> | 2026-04-30 22:01:53 +0800 |
| commit | db1c6676a13798ee57dbac429a1d5045b60356fb (patch) | |
| tree | 5ff305c09686de50bbcac404c1954e42c26ba494 /scripts/scroll.js | |
| parent | 97fa8f57fbefcbfa6b3e56c31a1e5b60ef1a9e37 (diff) | |
quite a big commit
Diffstat (limited to 'scripts/scroll.js')
| -rw-r--r-- | scripts/scroll.js | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/scripts/scroll.js b/scripts/scroll.js deleted file mode 100644 index ac2be07..0000000 --- a/scripts/scroll.js +++ /dev/null @@ -1,80 +0,0 @@ -document.addEventListener('scroll', function () {
- progress();
- // hideSidebar();
-});
-
-function progress() {
- const sections = document.getElementsByTagName("section");
- const nodes = document.getElementsByClassName("node");
-
- if (nodes[0]) {
- for (var i = 0; i < sections.length; i++) {
- if (isInViewport(sections[i])) {
- nodes[i].style.width = "22px";
- nodes[i].style.height = "22px";
- nodes[i].style.backgroundColor = "black";
- }
- else {
- nodes[i].style.width = "13px";
- nodes[i].style.height = "13px";
- nodes[i].style.backgroundColor = "#555";
- }
- }
- }
-}
-
-function hideSidebar() {
- const sidebar = document.getElementById("sidebar");
- const progressContainer = document.getElementById("progressContainer");
- const sections = document.getElementsByTagName("section");
-
- if (!progressContainer) {
- return;
- }
-
- if (screen.width <= 600) {
- if (window.scrollY >= 100) {
- sidebar.style.left = "-80px";
-
- for (var i = 0; i < sections.length; i++) {
- sections[i].style.marginLeft = 0;
- }
-
- if (progressContainer) {
- progressContainer.style.left = "-11px";
- }
- }
- else {
- sidebar.style.left = "0";
-
- for (var i = 0; i < sections.length; i++) {
- sections[i].style.marginLeft = "70px";
- }
-
- if (progressContainer) {
- progressContainer.style.left = "61px";
- }
- }
- }
- else {
- sidebar.style.left = "0";
- progressContainer.style.left = "61px";
- }
-}
-
-function isInViewport(element) {
- const rect = element.getBoundingClientRect();
- const visibleHeight = Math.min(rect.bottom, window.innerHeight) - Math.max(rect.top, 0);
- const visibleWidth = Math.min(rect.right, window.innerWidth) - Math.max(rect.left, 0);
- const elementHeight = rect.height;
- const elementWidth = rect.width;
- const halfElementHeight = elementHeight / 2;
- const halfElementWidth = elementWidth / 2;
-
- return (
- visibleHeight >= halfElementHeight &&
- visibleWidth >= halfElementWidth
- );
-}
-
-
|
