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 75a88d7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/fsm-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ export default {
$sideInner.style.position = 'absolute';
$sideInner.style.top = 'auto';
$sideInner.style.bottom = '0';
console.log(_d);
}
}
13 changes: 11 additions & 2 deletions src/fsm-transitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ export default {
to: states.FINISH,
when: (d) => [
d.isSideInnerWithinPath === true,
d.viewportTop + d.sideInnerHeight > d.finishPoint
d.isSideInnerWithinViewport === false,
d.viewportBottom > d.finishPoint
]
},
{
to: states.FINISH,
when: (d) => [
d.isSideInnerWithinPath === true,
d.isSideInnerWithinViewport === true,
d.viewportTop + d.sideInnerHeight + d.bottomSpacing > d.finishPoint
]
},
{
Expand Down Expand Up @@ -60,7 +69,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
11 changes: 6 additions & 5 deletions test/transitions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,12 @@ describe('transitions', function() {
// isSideInnerWithinPath === true
describe('when height(content) > height(sidebarInner)', () => {
beforeEach(async () => {
setContentHeight(sidebarInnerHeight * 2);
setContentHeight(sidebarInnerHeight * 1.5);
await nextFrame();
});

it('START => BOTTOM_FIXED', async () => {
it.only('START => BOTTOM_FIXED', async () => {
await scrollTo();
await scrollTo(getElementBottom(sidebarInnerElement) - window.innerHeight + 1);
await forceUpdate();
expectTransitionTo(BOTTOM_FIXED);
Expand All @@ -220,7 +221,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 +275,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 +409,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 75a88d7

Please sign in to comment.