From d953c240f3e840795955128543d91512c2eb83ae Mon Sep 17 00:00:00 2001 From: Sergey Vinogradov Date: Sun, 28 Nov 2021 12:10:49 +0300 Subject: [PATCH] fix: fix START => FINISH transition for sidebar not exceeding viewport --- src/fsm-transitions.js | 5 +++-- test/transitions.test.js | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/fsm-transitions.js b/src/fsm-transitions.js index f8f81a9..d1ef63c 100644 --- a/src/fsm-transitions.js +++ b/src/fsm-transitions.js @@ -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 ] }, { @@ -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, diff --git a/test/transitions.test.js b/test/transitions.test.js index eb8bdad..71d543b 100644 --- a/test/transitions.test.js +++ b/test/transitions.test.js @@ -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(); }); @@ -220,7 +220,7 @@ describe('transitions', function() { await forceUpdate(); expectTransitionTo(BOTTOM_FIXED); - setContentHeight(sidebarInnerHeight / 2); + setContentHeight(sidebarInnerHeight / 1.5); await forceUpdate(); expectTransitionTo(START); }); @@ -274,7 +274,7 @@ describe('transitions', function() { await forceUpdate(); expectTransitionTo(UNFIXED); - setContentHeight(sidebarInnerHeight / 2); + setContentHeight(sidebarInnerHeight / 1.5); await forceUpdate(); expectTransitionTo(START); }); @@ -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); });