Skip to content

Commit d953c24

Browse files
committed
fix: fix START => FINISH transition for sidebar not exceeding viewport
1 parent 7283b86 commit d953c24

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/fsm-transitions.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export default {
66
to: states.FINISH,
77
when: (d) => [
88
d.isSideInnerWithinPath === true,
9-
d.viewportTop + d.sideInnerHeight > d.finishPoint
9+
d.viewportTop + d.sideInnerHeight + d.bottomSpacing > d.finishPoint,
10+
d.viewportBottom > d.finishPoint
1011
]
1112
},
1213
{
@@ -60,7 +61,7 @@ export default {
6061
},
6162
{
6263
to: states.FINISH,
63-
when: (d) => [d.viewportTop + d.sideInnerHeight > d.finishPoint]
64+
when: (d) => [d.viewportBottom > d.finishPoint]
6465
},
6566
{
6667
to: states.TOP_FIXED,

test/transitions.test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ describe('transitions', function() {
205205
// isSideInnerWithinPath === true
206206
describe('when height(content) > height(sidebarInner)', () => {
207207
beforeEach(async () => {
208-
setContentHeight(sidebarInnerHeight * 2);
208+
setContentHeight(sidebarInnerHeight * 1.5);
209209
await nextFrame();
210210
});
211211

@@ -220,7 +220,7 @@ describe('transitions', function() {
220220
await forceUpdate();
221221
expectTransitionTo(BOTTOM_FIXED);
222222

223-
setContentHeight(sidebarInnerHeight / 2);
223+
setContentHeight(sidebarInnerHeight / 1.5);
224224
await forceUpdate();
225225
expectTransitionTo(START);
226226
});
@@ -274,7 +274,7 @@ describe('transitions', function() {
274274
await forceUpdate();
275275
expectTransitionTo(UNFIXED);
276276

277-
setContentHeight(sidebarInnerHeight / 2);
277+
setContentHeight(sidebarInnerHeight / 1.5);
278278
await forceUpdate();
279279
expectTransitionTo(START);
280280
});
@@ -408,7 +408,7 @@ describe('transitions', function() {
408408
});
409409

410410
it('START => FINISH', async () => {
411-
await scrollTo(getElementBottom(contentElement) - window.innerHeight);
411+
await scrollTo(getElementBottom(contentElement) - window.innerHeight + 1);
412412
await forceUpdate();
413413
expectTransitionTo(FINISH);
414414
});

0 commit comments

Comments
 (0)