Skip to content

Commit f649234

Browse files
committed
adjust
1 parent 506ea12 commit f649234

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

src/js-scroll-effect-module.js

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -253,33 +253,41 @@ export default class SCROLL_EFFECT_MODULE {
253253
this.state.NumScrolltopPre = this.state.NumScrolltop;
254254
}
255255

256-
_ActionChange(){
256+
_ActionChange(_type){
257257
if(!this.state.PosList.length) return false;
258258

259-
this.state.PosList.forEach(el => {
260-
if (el.active) {
259+
for (let _i = 0; _i < this.state.PosList.length; _i++) {
260+
const _item_pre = this.state.PosList[_i - 1];
261+
const _item = this.state.PosList[_i];
262+
263+
if (_item.active) {
261264
// activeな場合の処理
262-
if (!DOM.hasClass(el.el, this.config.classNameInview)) {
263-
el.count++;
264-
if (this.config.classNameInview) DOM.addClass(el.el, this.config.classNameInview);
265+
if (!DOM.hasClass(_item.el, this.config.classNameInview)) {
266+
_item.count++;
267+
if (this.config.classNameInview) DOM.addClass(_item.el, this.config.classNameInview);
265268
// Inコールバック関数の呼び出し
266-
this.callCallback(this.config.on.In, el, el.index, el.dataset.scrollName);
269+
this.callCallback(this.config.on.In, _item, _item.index, _item.dataset.scrollName);
267270
}
268271
} else {
269272
// activeでない場合の処理
270-
if (this.config.displayReverse && DOM.hasClass(el.el, this.config.classNameInview)) {
271-
DOM.removeClass(el.el, this.config.classNameInview);
273+
if (this.config.displayReverse && DOM.hasClass(_item.el, this.config.classNameInview)) {
274+
DOM.removeClass(_item.el, this.config.classNameInview);
272275
// Outコールバック関数の呼び出し
273-
this.callCallback(this.config.on.Out, el, el.index, el.dataset.scrollName);
276+
this.callCallback(this.config.on.Out, _item, _item.index, _item.dataset.scrollName);
274277
}
275278
}
279+
276280
// changingフラグのチェック
277-
if (el.changing) {
278-
el.changing = false;
281+
if (_item.changing) {
282+
_item.changing = false;
283+
284+
// アクティブの増減によってcallbackに渡すitemを変更
285+
let _item_fix = _type === 'down' ? _item : _item_pre;
286+
279287
// Changeコールバック関数の呼び出し
280-
this.callCallback(this.config.on.Change, el, el.index, el.dataset.scrollName);
288+
this.callCallback(this.config.on.Change, _item_fix, _item_fix.index, _item_fix.dataset.scrollName);
281289
}
282-
});
290+
}
283291
}
284292

285293
// コールバック関数の呼び出しを行うためのユーティリティ関数

0 commit comments

Comments
 (0)