Skip to content

Commit 9fb0113

Browse files
committed
表示するタイミングと、非表示にするタイミングを個別に調整可能に。
1 parent ab05a72 commit 9fb0113

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

src/js-scroll-effect-module.js

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export default class SCROLL_EFFECT_MODULE {
2626

2727
displayRatio : 0.8,
2828
displayReverse : false,
29+
displayRatioReverse: null,
2930

3031
firstDelay : 10,
3132
firstDelaySteps : 100,
@@ -50,6 +51,15 @@ export default class SCROLL_EFFECT_MODULE {
5051
...options
5152
};
5253

54+
// adjust ratio value.
55+
if( !this.config.displayRatioReverse ) {
56+
this.config.displayRatioReverse = this.config.displayRatio;
57+
} else {
58+
if( this.config.displayRatioReverse < this.config.displayRatio ) {
59+
this.config.displayRatioReverse = this.config.displayRatio;
60+
}
61+
}
62+
5363
if(this.config.autoStart) this.Init();
5464
}
5565

@@ -151,20 +161,51 @@ export default class SCROLL_EFFECT_MODULE {
151161
// Store element state at PosList.
152162
this.state.PosList.map((el)=>{
153163

164+
if(this.config.displayRatio === this.config.displayRatioReverse){
154165
if( this.state.NumScrolltop + ( this.NumWindowHeight * this.config.displayRatio ) > el.pos ){
155-
156166
// First count up.
157167
if(method === 'load'){
158168
el.count++;
159169
}
160170

161171
// 「active」Set of lists
172+
el.active = true;
162173
this.state.PosListFix.push(el);
163174
} else {
164175

165176
// 「none active」Set of lists
177+
el.active = false;
166178
this.state.PosListNoneFix.push(el);
167179
}
180+
}
181+
182+
if(this.config.displayRatio !== this.config.displayRatioReverse){
183+
if( this.state.NumScrolltop + ( this.NumWindowHeight * this.config.displayRatio ) > el.pos ){
184+
// First count up.
185+
if(method === 'load'){
186+
el.count++;
187+
}
188+
189+
// 「active」Set of lists
190+
el.active = true;
191+
this.state.PosListFix.push(el);
192+
} else {
193+
if( this.state.NumScrolltop + ( this.NumWindowHeight * this.config.displayRatioReverse ) > el.pos ){
194+
if(el.active){
195+
// 「active」Set of lists
196+
this.state.PosListFix.push(el);
197+
} else {
198+
// 「none active」Set of lists
199+
this.state.PosListNoneFix.push(el);
200+
}
201+
} else {
202+
// 「none active」Set of lists
203+
el.active = false;
204+
this.state.PosListNoneFix.push(el);
205+
}
206+
}
207+
208+
}
168209
});
169210

170211
if(this.config.acceleration){

0 commit comments

Comments
 (0)