Skip to content

Commit a172181

Browse files
committed
fix: perf issue
1 parent f8c51e3 commit a172181

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

src/components/BaseNavbar.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const links = [
2121
let dummy = ["delay-100", "delay-200", "delay-300", "delay-400", "delay-500", "delay-600", "delay-700", "delay-800", "delay-900"];
2222
---
2323

24-
<header class="absolute top-0 left-0 w-full text-white z-999 py-6 sm:(py-12) flex items-center justify-between px-1/12" x-data="{open:true}">
24+
<header class="absolute top-0 left-0 w-full text-white z-999 py-6 sm:(py-12) flex items-center justify-between px-1/12" x-data="{open: false}">
2525
<div class="flex gap-32 items-center justify-between flex-grow relative">
2626
<a href="/" class="text-2xl sm:text-3xl font-logo">Andka</a>
2727
<nav
@@ -47,7 +47,7 @@ let dummy = ["delay-100", "delay-200", "delay-300", "delay-400", "delay-500", "d
4747
</div>
4848
</nav>
4949
<div class="lg:hidden" @click="open = !open">
50-
<div class="w-5 h-5 relative ">
50+
<div class="w-5 h-5 relative">
5151
<div
5252
class="absolute left-0 w-full h-2px bg-white top-1 duration-500 transition-all ease-in-out"
5353
:style="open ? 'transform:rotate(45deg); top: 50%' : 'transform:rotate(0deg);'">

src/components/home/Expertise.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const expertise = [
1818
];
1919
---
2020

21-
<div class="w-full py-32 overflow-x-hidden overflow-y-visible px-8 flex items-center justify-center flex-col gap-16" x-data="{i: 0}">
21+
<div class="w-full py-32 overflow-x-hidden px-8 flex items-center justify-center flex-col gap-16" x-data="{i: 0}">
2222
<div class="border-1 border-#fff2 bg-#ffffff08 relative rounded-3xl grid grid-cols-1 sm:grid-cols-3 max-w-6xl backdrop-blur-xl">
2323
{
2424
expertise.map((el, index) => (

src/components/home/GIT.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
---
44

5-
<div class="w-full flex flex-col sm:(items-center justify-center) pt-32 px-8 xl:(p-32 pb-46) gap-8 relative mt-8">
5+
<div class="w-full flex flex-col sm:(items-center justify-center) pt-32 pb-70 px-8 xl:(p-32 pb-46) gap-8 relative mt-8">
66
<h1 class="text-5xl sm:(text-6xl text-center) font-bold font-heading">Let's get in touch!</h1>
77
<section class="grid gap-2 ">
88
<p class="text-xl sm:(text-2xl text-center) font-300 w-full">Work with me, or just say hi! I'd love to hear from you.</p>

src/components/home/Hero.astro

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
<main class="w-full relative min-h-screen w-full flex items-center justify-center">
1+
<main class="w-full relative min-h-screen w-full flex items-center justify-center overflow-hidden">
22
<div
3-
class="w-90vw -z-10 h-80vw rounded-full absolute top-0 left-1/2 -translate-y-3/5 -translate-x-1/2 blur-300px scale-y-70%"
4-
style="background-image: radial-gradient(circle,#442464 0%, #9d53d6 50%, #5ee3f0 80%);">
3+
class="-z-10 w-70 h-70 blur-150 -translate-y-1/2 lg:(w-90vw h-80vw -translate-y-3/5 -translate-x-1/2 blur-300px left-1/2) rounded-full absolute top-0 scale-y-70% bg-purple"></div>
54
</div>
65

76
<div class="z-90 flex p-8 lg:p-0 flex-col gap-8 sm:(gap-12 text-center items-center justify-center) text-white">
@@ -15,7 +14,8 @@
1514
</div>
1615
</a>
1716
</div>
18-
<div class="absolute w-full top-1/2 left-1/2 -translate-y-1/2 -translate-x-1/2 -z-11 overflow-hidden flex items-center justify-center opacity-50 sm:opacity-100">
17+
<div
18+
class="absolute w-full top-1/2 left-1/2 -translate-y-1/2 -translate-x-1/2 -z-11 overflow-hidden flex items-center justify-center opacity-50 sm:opacity-100">
1919
<canvas width="1000" height="1000" id="herocanvas" class="w-1000px h-1000px" aria-hidden="true"> </canvas>
2020
</div>
2121
</main>
@@ -31,7 +31,7 @@
3131
const hWidth = width / 2;
3232
const hHeight = height / 2;
3333
const particles = [];
34-
const particlesCount = 200;
34+
const particlesCount = Math.min(100, Math.floor(window.innerWidth / 10));
3535
const defaultPartSpeed = 0.005;
3636

3737
let bgOpacity = 1;
@@ -75,7 +75,6 @@
7575
this.time -= this.speed;
7676

7777
this.θ = 2 * Math.PI * this.u + this.time;
78-
7978
this.φ = Math.acos(2 * this.v - 1) - Math.PI * 0.5;
8079

8180
this.x = this.radius * Math.sin(this.θ) * Math.cos(this.φ);
@@ -99,11 +98,14 @@
9998
}
10099

101100
render(ctx: CanvasRenderingContext2D) {
102-
const hSize = this.size / 2;
101+
const x = this.x + hWidth;
102+
const y = this.y + hHeight;
103+
const radius = this.size / 2;
103104

104105
ctx.fillStyle = this.getColor(ctx);
105-
106-
ctx.fillRect(hWidth + this.x - hSize, hHeight + this.y - hSize, this.size, this.size);
106+
ctx.beginPath();
107+
ctx.arc(x, y, radius, 0, Math.PI * 2);
108+
ctx.fill();
107109
}
108110

109111
get data() {

0 commit comments

Comments
 (0)