-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
120 lines (107 loc) · 2.91 KB
/
script.js
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
function init() {
gsap.registerPlugin(ScrollTrigger);
const locoScroll = new LocomotiveScroll({
el: document.querySelector(".main"),
smooth: true
});
locoScroll.on("scroll", ScrollTrigger.update);
ScrollTrigger.scrollerProxy(".main", {
scrollTop(value) {
return arguments.length ? locoScroll.scrollTo(value, 0, 0) : locoScroll.scroll.instance.scroll.y;
},
getBoundingClientRect() {
return { top: 0, left: 0, width: window.innerWidth, height: window.innerHeight };
},
pinType: document.querySelector(".main").style.transform ? "transform" : "fixed"
});
ScrollTrigger.addEventListener("refresh", () => locoScroll.update());
ScrollTrigger.refresh();
}
init()
var crsr = document.querySelector(".cursor")
var main = document.querySelector(".main")
document.addEventListener("mousemove",function(dets){
crsr.style.left = dets.x + 20+"px"
crsr.style.top = dets.y + 20+"px"
})
gsap.from(".page1 h1,.page1 h2", {
y: 10,
rotate: 10,
opacity: 0,
delay: 0.3,
duration: 0.7
})
var tl = gsap.timeline({
scrollTrigger: {
trigger: ".page1 h1",
scroller: ".main",
// markers:true,
start: "top 27%",
end: "top 0",
scrub: 3
}
})
tl.to(".page1 h1", {
x: -100,
}, "anim")
tl.to(".page1 h2", {
x: 100
}, "anim")
tl.to(".page1 video", {
width: "90%"
}, "anim")
var tl2 = gsap.timeline({
scrollTrigger: {
trigger: ".page1 h1",
scroller: ".main",
// markers:true,
start: "top -115%",
end: "top -120%",
scrub: 3
}
})
tl2.to(".main", {
backgroundColor: "#fff",
})
var tl3 = gsap.timeline({
scrollTrigger: {
trigger: ".page1 h1",
scroller: ".main",
// markers:true,
start: "top -280%",
end: "top -300%",
scrub: 3
}
})
tl3.to(".main",{
backgroundColor:"#0F0D0D"
})
var boxes = document.querySelectorAll(".box")
boxes.forEach(function(elem){
elem.addEventListener("mouseenter",function(){
var att = elem.getAttribute("data-image")
crsr.style.width = "470px"
crsr.style.height = "370px"
crsr.style.borderRadius = "0"
crsr.style.backgroundImage = `url(${att})`
})
elem.addEventListener("mouseleave",function(){
elem.style.backgroundColor = "transparent"
crsr.style.width = "20px"
crsr.style.height = "20px"
crsr.style.borderRadius = "50%"
crsr.style.backgroundImage = `none`
})
})
var h4 = document.querySelectorAll("#nav h4")
var purple = document.querySelector("#purple")
h4.forEach(function(elem){
elem.addEventListener("mouseenter",function(){
purple.style.display = "block"
purple.style.opacity = "1"
})
elem.addEventListener("mouseleave",function(){
purple.style.display = "none"
purple.style.opacity = "0"
})
})