Skip to content

Commit

Permalink
fix: fix START => FINISH transition for sidebar not exceeding viewport
Browse files Browse the repository at this point in the history
  • Loading branch information
vursen committed Nov 28, 2021
1 parent 7283b86 commit d953c24
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/fsm-transitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ export default {
to: states.FINISH,
when: (d) => [
d.isSideInnerWithinPath === true,
d.viewportTop + d.sideInnerHeight > d.finishPoint
d.viewportTop + d.sideInnerHeight + d.bottomSpacing > d.finishPoint,
d.viewportBottom > d.finishPoint
]
},
{
Expand Down Expand Up @@ -60,7 +61,7 @@ export default {
},
{
to: states.FINISH,
when: (d) => [d.viewportTop + d.sideInnerHeight > d.finishPoint]
when: (d) => [d.viewportBottom > d.finishPoint]
},
{
to: states.TOP_FIXED,
Expand Down
8 changes: 4 additions & 4 deletions test/transitions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ describe('transitions', function() {
// isSideInnerWithinPath === true
describe('when height(content) > height(sidebarInner)', () => {
beforeEach(async () => {
setContentHeight(sidebarInnerHeight * 2);
setContentHeight(sidebarInnerHeight * 1.5);
await nextFrame();
});

Expand All @@ -220,7 +220,7 @@ describe('transitions', function() {
await forceUpdate();
expectTransitionTo(BOTTOM_FIXED);

setContentHeight(sidebarInnerHeight / 2);
setContentHeight(sidebarInnerHeight / 1.5);
await forceUpdate();
expectTransitionTo(START);
});
Expand Down Expand Up @@ -274,7 +274,7 @@ describe('transitions', function() {
await forceUpdate();
expectTransitionTo(UNFIXED);

setContentHeight(sidebarInnerHeight / 2);
setContentHeight(sidebarInnerHeight / 1.5);
await forceUpdate();
expectTransitionTo(START);
});
Expand Down Expand Up @@ -408,7 +408,7 @@ describe('transitions', function() {
});

it('START => FINISH', async () => {
await scrollTo(getElementBottom(contentElement) - window.innerHeight);
await scrollTo(getElementBottom(contentElement) - window.innerHeight + 1);
await forceUpdate();
expectTransitionTo(FINISH);
});
Expand Down

0 comments on commit d953c24

Please sign in to comment.