Skip to content

Commit 8b6eec0

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

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

src/fsm-transitions.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@ export default {
66
to: states.FINISH,
77
when: (d) => [
88
d.isSideInnerWithinPath === true,
9-
d.viewportTop + d.sideInnerHeight > d.finishPoint
9+
d.isSideInnerWithinViewport === false,
10+
d.viewportBottom > d.finishPoint
11+
]
12+
},
13+
{
14+
to: states.FINISH,
15+
when: (d) => [
16+
d.isSideInnerWithinPath === true,
17+
d.isSideInnerWithinViewport === true,
18+
d.viewportTop + d.sideInnerHeight + d.bottomSpacing > d.finishPoint
1019
]
1120
},
1221
{
@@ -60,7 +69,7 @@ export default {
6069
},
6170
{
6271
to: states.FINISH,
63-
when: (d) => [d.viewportTop + d.sideInnerHeight > d.finishPoint]
72+
when: (d) => [d.viewportBottom > d.finishPoint]
6473
},
6574
{
6675
to: states.TOP_FIXED,

test/transitions.test.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,12 @@ 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

212-
it('START => BOTTOM_FIXED', async () => {
212+
it.only('START => BOTTOM_FIXED', async () => {
213+
await scrollTo();
213214
await scrollTo(getElementBottom(sidebarInnerElement) - window.innerHeight + 1);
214215
await forceUpdate();
215216
expectTransitionTo(BOTTOM_FIXED);
@@ -220,7 +221,7 @@ describe('transitions', function() {
220221
await forceUpdate();
221222
expectTransitionTo(BOTTOM_FIXED);
222223

223-
setContentHeight(sidebarInnerHeight / 2);
224+
setContentHeight(sidebarInnerHeight / 1.5);
224225
await forceUpdate();
225226
expectTransitionTo(START);
226227
});
@@ -274,7 +275,7 @@ describe('transitions', function() {
274275
await forceUpdate();
275276
expectTransitionTo(UNFIXED);
276277

277-
setContentHeight(sidebarInnerHeight / 2);
278+
setContentHeight(sidebarInnerHeight / 1.5);
278279
await forceUpdate();
279280
expectTransitionTo(START);
280281
});
@@ -408,7 +409,7 @@ describe('transitions', function() {
408409
});
409410

410411
it('START => FINISH', async () => {
411-
await scrollTo(getElementBottom(contentElement) - window.innerHeight);
412+
await scrollTo(getElementBottom(contentElement) - window.innerHeight + 1);
412413
await forceUpdate();
413414
expectTransitionTo(FINISH);
414415
});

0 commit comments

Comments
 (0)