-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStory.jsx
More file actions
101 lines (88 loc) · 2.9 KB
/
Story.jsx
File metadata and controls
101 lines (88 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import React, { useRef } from 'react';
import AnimatedTitle from './AnimatedTitle';
import gsap from 'gsap';
import RoundedCorners from './RoundedCorners';
import Button from './Button';
const Story = () => {
const frameRef = useRef('null');
const handleMouseLeave = () => {
const element = frameRef.current;
if (!element) return;
gsap.to(element, {
rotateX: 0,
rotateY: 0,
duration: 0.3,
ease: 'power1.inOut',
});
};
const handleMouseMove = (e) => {
const { clientX, clientY } = e;
const element = frameRef.current;
if (!element) return;
const rect = element.getBoundingClientRect();
const x = clientX - rect.left;
const y = clientY - rect.top;
const centerX = rect.width / 2;
const centerY = rect.height / 2;
const rotateX = ((y - centerY) / centerY) * -10;
const rotateY = ((x - centerX) / centerX) * 10;
gsap.to(element, {
rotateX,
rotateY,
duration: 0.3,
transformPerspective: 500,
ease: 'power1.inOut',
});
};
return (
<section
id="story"
className="min-h-dvh w-screen bg-black text-blue-50"
>
<div className="flex size-full flex-col items-center py-10 pb-24">
<p className="font-general text-sm uppercase md:text-[10px]">
the multiverse ip world
</p>
<div className="relative size-full">
<AnimatedTitle
title="The st<b>o</b>ry of <br /> a hidden real<b>m</b>"
sectionId="#story"
containerClass="mt-5 pointer-events-none mix-blend-difference relative z-10"
/>
<div className="story-img-container">
<div className="story-img-mask">
<div className="story-img-content">
<img
ref={frameRef}
onMouseLeave={handleMouseLeave}
onMouseUp={handleMouseLeave}
onMouseEnter={handleMouseLeave}
onMouseMove={handleMouseMove}
src="/img/entrance.webp"
alt="entrance"
className="object-contain"
/>
</div>
</div>
<RoundedCorners />
</div>
</div>
<div className="-mt-80 flex w-full justify-center md:-mt-64 md:me-44 md:justify-end">
<div className="flex h-full w-fit flex-col items-center md:items-start">
<p className="mt-3 max-w-sm text-center font-circular-web text-violet-50 md:text-start">
Where realms converge, lies Zentry and the boundless
pillar. Discover its secrets and shape your fate amidst
infinite opportunities.
</p>
<Button
id="realm-button"
title="discover prologue"
containerClass="mt-5 bg-blue-50"
/>
</div>
</div>
</div>
</section>
);
};
export default Story;