Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent sidebar from jumping when in START or UNFIXED state #14

Merged
merged 2 commits into from
Nov 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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