-
Notifications
You must be signed in to change notification settings - Fork 0
/
beltScroll.js
47 lines (38 loc) · 1.54 KB
/
beltScroll.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
import { Tween24 } from "tween24";
// スクロールする速さ
const VELOCITY = 100;
const firstText = document.querySelector(".beltScroll .firstText");
const secondText = document.querySelector(".beltScroll .secondText");
// まえ側のテキスト
const firstTextTween = Tween24.serial(
Tween24.prop(firstText).x(0),
Tween24.tweenVelocity(firstText, VELOCITY).x("-100%")
);
// うしろ側のテキスト(見きれないようにする)
const secondTextTween = Tween24.serial(
Tween24.prop(secondText).x("100%"),
Tween24.tweenVelocity(secondText, VELOCITY).x(0)
);
// 両者を同時に動かす
const beltTween = Tween24.parallel(firstTextTween, secondTextTween);
// ベルトスクロールをループ実行する
Tween24.loop(0, beltTween).play();
/*=== 複数バージョン ===*/
document.querySelectorAll(".multiBeltScroll").forEach((element) => {
const firstText = element.querySelector(".firstText");
const secondText = element.querySelector(".secondText");
// まえ側のテキスト
const firstTextTween = Tween24.serial(
Tween24.prop(firstText).x(0),
Tween24.tweenVelocity(firstText, VELOCITY).x("-100%")
);
// うしろ側のテキスト(見きれないようにする)
const secondTextTween = Tween24.serial(
Tween24.prop(secondText).x("100%"),
Tween24.tweenVelocity(secondText, VELOCITY).x(0)
);
// 両者を同時に動かす
const beltTween = Tween24.parallel(firstTextTween, secondTextTween);
// ベルトスクロールをループ実行する
Tween24.loop(0, beltTween).play();
});