-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.js
52 lines (44 loc) · 1.36 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
console.log('connecté !');
// Division en lignes + ajout d'une div lineMask à chaque ligne
function run(){
let paragraphs = document.querySelectorAll('#paragraph');
console.log(paragraphs);
paragraphs = new SplitType (paragraphs, {types: 'lines'});
console.log("division par lignes ok");
let lineMask = document.createElement('div');
console.log("div lineMask créé");
lineMask.classList.add('line-mask');
console.log("classe line-mask ajoutée");
let lines = document.querySelectorAll('.line');
console.log(lines);
lines.forEach((line)=> {
line.appendChild(lineMask.cloneNode(true));
})
}
run();
// GSAP
let lines = document.querySelectorAll('.line');
console.log(lines);
function onScroll() {
lines.forEach((line)=> {
// Prépa triggerElement et targetElement pour GSAP
let triggerElement = line;
console.log(triggerElement);
let targetElement = line.querySelector('.line-mask');
console.log(targetElement);
// create a timeline and detect line trigger
let tl = gsap.timeline({
scrollTrigger: {
trigger: triggerElement,
start: "top center",
end: "bottom center",
scrub: 3
}
});
tl.to(targetElement, {
width: "0%",
duration: 1
});
});
}
onScroll();