-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
119 lines (101 loc) · 2.87 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
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";
})
var tl = gsap.timeline({
scrollTrigger:{
trigger: ".page1 h1",
scroller: ".main",
markers: true,
start:"top 30%",
end:"top 0",
scrub:2,
}
});
tl.to(".page1 h1", {
x:-90,
}, "anim")
tl.to(".page1 h2", {
x:90,
}, "anim")
tl.to(".page1 video", {
width:"90%",
}, "anim")
var tl2 = gsap.timeline({
scrollTrigger:{
trigger: ".page1 h1",
scroller: ".main",
markers: true,
start:"top -110%",
end:"top -120",
scrub:2,
}
})
tl2.to(".main", {
backgroundColor: "#fff",
})
var tl3 = gsap.timeline({
scrollTrigger:{
trigger: ".page1 h1",
scroller: ".main",
markers: true,
start:"top -320%",
end:"top -380",
scrub:2,
}
})
tl3.to(".main", {
backgroundColor: "#111",
})
var boxes = document.querySelectorAll(".box")
boxes.forEach(function(elem){
elem.addEventListener("mouseenter", function(){
var att = elem.getAttribute("data-image")
crsr.style.width = "400px"
crsr.style.height = "350px"
crsr.style.borderRadius = "0"
crsr.style.backgroundImage = `url(${att})`
})
elem.addEventListener("mouseleave", function(){
elem.style.backgroundColor = "transparent"
var att = elem.getAttribute("data-image")
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"
})
})