Skip to content

Commit

Permalink
fix: stop regenerating grid on scroll (mobile)
Browse files Browse the repository at this point in the history
  • Loading branch information
Itz-fork committed Dec 3, 2023
1 parent 0c4a59d commit b455709
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
dist
.parcel-cache
2 changes: 1 addition & 1 deletion publish
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ PKGM="pnpm"
GHP_BRANCH="gh-pages"
UPSTREAM_NM="ghupstream"
REPO_URL="https://github.com/Itz-fork/itz-fork.github.io.git"
FLAGS="--no-optimize"
FLAGS=""


echo -e "> Creating build branch - ${GHP_BRANCH}"
Expand Down
16 changes: 0 additions & 16 deletions src/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,6 @@ button.sc_btns:hover:not(button.sc_btns) {
overflow: auto;
}

.line {
margin-top: var(--vline-mh);
border-left: 2px solid #0000;
border-image: linear-gradient(var(--z-blue), var(--z-purple), var(--z-blue)) 10 stretch;
min-height: 60vh;
margin-left: 4vw;
position: absolute;
}

.line-con {
flex-direction: column;
margin-top: 10rem;
display: flex;
position: relative;
}

.greet {
color: var(--z-white-text);
font-size: 2rem;
Expand Down
4 changes: 2 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h1>Hirusha</h1>

<p>A teenager who loves to build stuff</p><br>

<a onclick="SGotoUntil()"><button class="gradnime">Lean more _*</button></a>
<a href="#about"><button class="gradnime">Lean more _*</button></a>
</section>


Expand All @@ -37,7 +37,7 @@ <h2>About me</h2>
<br><br>
Over the next 5 years, I learned more and more things about computers and software. Needless to say, during those
years I also learned about front-end development thus making me a full-stack developer.
Check out <a onclick="SGotoUntil()" data-linker>my skills</a> 💪
Check out <a ohref="#skills" data-linker>my skills</a> 💪
</p>
</section>

Expand Down
36 changes: 22 additions & 14 deletions src/js/effects.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
// Author: Itz-fork


// Pre-defined variables
const intWidth = window.innerWidth
const intHeight = window.innerHeight
const container = document.getElementById("sqbg");
const cursor = document.getElementById("cursor");

const size = 100;
let columns = 0, rows = 0;
const codes = [
Expand Down Expand Up @@ -39,9 +46,9 @@ const codes = [
"struct Code",
"interface Life"
];
const container = document.getElementById("sqbg");
const cursor = document.getElementById("cursor");
// Background


// Background grid
function AddSqrs(sq) {
while (sq > 0) {
let sqrel = document.createElement("div");
Expand All @@ -60,7 +67,17 @@ const CalcGrid = () => {
AddSqrs(columns * rows);
};
CalcGrid();
window.onresize = () => CalcGrid();

// Generate grid on resize
window.onresize = () => {
// fix: stop regenerating grid on scroll (mobile)
if (curWidth == window.innerWidth && curHeight == window.innerHeight) {
return
}
CalcGrid()
};

// Mouse move effect
window.onmousemove = (ev) => {
const position = Math.floor(ev.x / 100) + Math.floor(ev.y / 100) * columns;
const el = container.children[position];
Expand All @@ -81,13 +98,4 @@ window.onmousemove = (ev) => {
]
}, 2000);
} catch (e) { }
};

// Scroll helper
function SGotoUntil(untilV = window.innerHeight) {
window.scrollBy({
top: untilV,
left: 100,
behavior: "smooth"
});
}
};

0 comments on commit b455709

Please sign in to comment.