Skip to content

Commit 8510830

Browse files
committed
- Fixed bug: continuousVerticall not working with fp-auto-height sections #4708
1 parent 7aeb09e commit 8510830

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed

src/js/infiniteScroll/createInfiniteSections.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
SLIDE_ACTIVE_SEL
99
} from '../common/selectors.js';
1010
import { getYmovement } from '../common/utilsFP.js';
11-
11+
import { getDestinationPosForInfiniteScroll, getTmpPosition } from './getPositions.js';
1212

1313
/**
1414
* Adds sections before or after the current one to create the infinite effect.
@@ -20,15 +20,16 @@ export function createInfiniteSections(v){
2020
// Scrolling down
2121
if (!v.isMovementUp) {
2222
// Move all previous sections to after the active section
23-
utils.after(activeSectionItem, utils.prevAll(activeSectionItem, SECTION_SEL).reverse());
23+
var prevSectionsReversed = utils.prevAll(activeSectionItem, SECTION_SEL).reverse();
24+
utils.after(activeSectionItem, prevSectionsReversed[0]);
2425
}
2526
else { // Scrolling up
2627
// Move all next sections to before the active section
2728
utils.before(activeSectionItem, utils.nextAll(activeSectionItem, SECTION_SEL));
2829
}
2930

3031
// Maintain the displayed position (now that we changed the element order)
31-
silentScroll(getState().activeSection.item.offsetTop);
32+
silentScroll(getTmpPosition(v));
3233

3334
// Maintain the active slides visible in the viewport
3435
keepSlidesPosition();
@@ -37,7 +38,7 @@ export function createInfiniteSections(v){
3738
v.wrapAroundElements = activeSectionItem;
3839

3940
// Recalculate animation variables
40-
v.dtop = v.element.offsetTop;
41+
v.dtop = getDestinationPosForInfiniteScroll(v);
4142
v.yMovement = getYmovement(getState().activeSection, v.element);
4243

4344
return v;
@@ -54,4 +55,3 @@ function keepSlidesPosition(){
5455
}
5556
}
5657

57-

src/js/infiniteScroll/fixPosition.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
SECTION_SEL,
88
SLIDE_ACTIVE_SEL
99
} from '../common/selectors.js';
10+
import { getTmpPosition } from './getPositions.js';
1011

1112
/**
1213
* Maintains the active slides in the viewport
@@ -33,10 +34,10 @@ export function continuousVerticalFixSectionOrder (v) {
3334
utils.before(utils.$(SECTION_SEL)[0], v.wrapAroundElements);
3435
}
3536
else {
36-
utils.after(utils.$(SECTION_SEL)[getState().sections.length -1 ], v.wrapAroundElements);
37+
utils.after(utils.$(SECTION_SEL)[getState().sections.length - 1], utils.prevAll(v.element, SECTION_SEL).reverse());
3738
}
3839

39-
silentScroll(getState().activeSection.item.offsetTop);
40+
silentScroll(getTmpPosition(v));
4041

4142
// Maintain the active slides visible in the viewport
4243
keepSlidesPosition();

src/js/infiniteScroll/getPositions.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as utils from '../common/utils.js';
2+
import { getState } from "../common/state.js";
3+
import { getDestinationPosition } from "../scroll/scrollPage.js";
4+
import { AUTO_HEIGHT } from '../common/selectors.js';
5+
6+
export function getTmpPosition(v){
7+
return utils.hasClass(getState().activeSection.item, AUTO_HEIGHT)
8+
? getDestinationPosition(getState().activeSection.item)
9+
: getState().activeSection.item.offsetTop;
10+
}
11+
12+
export function getDestinationPosForInfiniteScroll(v){
13+
// forcing the scroll to the bottom of the fp-auto-height section when scrolling up
14+
if(v.isMovementUp && utils.hasClass(v.element, AUTO_HEIGHT)){
15+
return getDestinationPosition(v.element) - utils.getWindowHeight() + v.element.offsetHeight;
16+
}
17+
18+
return v.element.offsetTop;
19+
}

src/js/scroll/scrollPage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ function onDestroy(){
151151
* Returns the destination Y position based on the scrolling direction and
152152
* the height of the section.
153153
*/
154-
function getDestinationPosition(element){
154+
export function getDestinationPosition(element){
155155
var elementHeight = element.offsetHeight;
156156
var elementTop = element.offsetTop;
157157

0 commit comments

Comments
 (0)