teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

4

訂正

2020/03/25 03:17

投稿

Lhankor_Mhy
Lhankor_Mhy

スコア37502

answer CHANGED
@@ -107,4 +107,20 @@
107
107
  }
108
108
  }
109
109
  });
110
+ ```
111
+
112
+
113
+ ### 訂正
114
+ ```js
115
+ const trigger = new ScrollTrigger.default({trigger:{
116
+ once: true, // same functionality as the `once` flag in v0.x
117
+ offset: {
118
+ element: {
119
+ y: 1.0 // note that we pass a float instead of an integer, when the
120
+ // offset is a float, it takes it as a percentage, in this
121
+ // case, add 100% of the height of the element, the same
122
+ // functionality as the `addHeight` flag in v0.x
123
+ }
124
+ },
125
+ }});
110
126
  ```

3

コメントを受けて追記3

2020/03/25 03:17

投稿

Lhankor_Mhy
Lhankor_Mhy

スコア37502

answer CHANGED
@@ -47,4 +47,64 @@
47
47
  }
48
48
  }
49
49
  });
50
+ ```
51
+
52
+ ### コメントを受けて追記3
53
+
54
+ ```html
55
+ <div class="feature_list">
56
+ <dl>
57
+ <dt class="animated fast" data-scroll="bounceInDown">
58
+ <img src="http://placehold.jp/1500x1500.png?text=img/index/top01.png" alt="">
59
+ </dt>
60
+ <dd>AA</dd>
61
+ </dl>
62
+ <dl>
63
+ <dt class="animated fast" data-scroll="fadeIn">
64
+ <img src="http://placehold.jp/1500x1500.png?text=img/index/top02.png" alt="">
65
+ </dt>
66
+ <dd>BB</dd>
67
+ </dl>
68
+ <dl>
69
+ <dt class="animated fast" data-scroll="fadeInLeft">
70
+ <img src="http://placehold.jp/1500x1500.png?text=img/index/top03.png" alt="">
71
+ </dt>
72
+ <dd>CC</dd>
73
+ </dl>
74
+ </div>
75
+ ```
76
+
77
+ ```js
78
+ const trigger = new ScrollTrigger.default({
79
+ once: true, // same functionality as the `once` flag in v0.x
80
+ offset: {
81
+ element: {
82
+ y: 1.0 // note that we pass a float instead of an integer, when the
83
+ // offset is a float, it takes it as a percentage, in this
84
+ // case, add 100% of the height of the element, the same
85
+ // functionality as the `addHeight` flag in v0.x
86
+ }
87
+ },
88
+ });
89
+ trigger.add('[data-scroll=bounceInDown]', {
90
+ toggle: {
91
+ class: {
92
+ in: 'bounceInDown',
93
+ }
94
+ }
95
+ });
96
+ trigger.add('[data-scroll=fadeIn]', {
97
+ toggle: {
98
+ class: {
99
+ in: 'fadeIn',
100
+ }
101
+ }
102
+ });
103
+ trigger.add('[data-scroll=fadeInLeft]', {
104
+ toggle: {
105
+ class: {
106
+ in: 'fadeInLeft',
107
+ }
108
+ }
109
+ });
50
110
  ```

2

コメントを受けて追記2

2020/03/25 01:15

投稿

Lhankor_Mhy
Lhankor_Mhy

スコア37502

answer CHANGED
@@ -21,4 +21,30 @@
21
21
  ```
22
22
  [GitHub - terwanerik/ScrollTrigger: Let your page react to scroll changes.](https://github.com/terwanerik/ScrollTrigger#how-to-use)
23
23
 
24
- とのことですから、`new ScrollTrigger.default()`とすればいいのではないでしょうか?
24
+ とのことですから、`new ScrollTrigger.default()`とすればいいのではないでしょうか?
25
+
26
+ ### コメントを受けて追記2
27
+
28
+ [Migrating from 0.x to 1.x | GitHub - terwanerik/ScrollTrigger: Let your page react to scroll changes.](https://github.com/terwanerik/ScrollTrigger#user-content-migrating-from-0x-to-1x)
29
+ ↑こちらの Another example for setting custom classes per toggle という一節をお読みいただければ、わかるのではないかと。
30
+
31
+ 一応念のため、当方で動作したコードも置いておきます。(解決手段に書かれていた変更は元に戻してください)
32
+ ```js
33
+ const trigger = new ScrollTrigger.default()
34
+ trigger.add('[data-scroll]', {
35
+ once: true, // same functionality as the `once` flag in v0.x
36
+ offset: {
37
+ element: {
38
+ y: 1.0 // note that we pass a float instead of an integer, when the
39
+ // offset is a float, it takes it as a percentage, in this
40
+ // case, add 100% of the height of the element, the same
41
+ // functionality as the `addHeight` flag in v0.x
42
+ }
43
+ },
44
+ toggle: {
45
+ class: {
46
+ in: 'bounceInDown',
47
+ }
48
+ }
49
+ });
50
+ ```

1

コメントを受けて追記

2020/03/24 08:52

投稿

Lhankor_Mhy
Lhankor_Mhy

スコア37502

answer CHANGED
@@ -3,10 +3,22 @@
3
3
 
4
4
  ネットの情報は玉石混交で、間違っていたり、古かったりすることがあります。
5
5
  最新の公式ドキュメントを読んでみてはいかがですか。
6
+
6
- > ```js
7
+ ```js
7
8
  // Create a new ScrollTrigger instance with default options
8
9
  const trigger = new ScrollTrigger()
9
10
  // Add all html elements with attribute data-trigger
10
11
  trigger.add('[data-trigger]')
11
12
  ```
12
- [ScrollTrigger - Let your page react to scroll changes](https://terwanerik.github.io/ScrollTrigger/)
13
+ [ScrollTrigger - Let your page react to scroll changes](https://terwanerik.github.io/ScrollTrigger/)
14
+  
15
+
16
+ ### コメントを受けて追記
17
+
18
+ ```js
19
+ // Create a new ScrollTrigger instance with default options
20
+ const trigger = new ScrollTrigger() // When not using npm, create a new instance with 'new ScrollTrigger.default()'
21
+ ```
22
+ [GitHub - terwanerik/ScrollTrigger: Let your page react to scroll changes.](https://github.com/terwanerik/ScrollTrigger#how-to-use)
23
+
24
+ とのことですから、`new ScrollTrigger.default()`とすればいいのではないでしょうか?