From e7850b44928ae99734afdd9508e752321756f3c5 Mon Sep 17 00:00:00 2001 From: Sergey Vinogradov Date: Sun, 28 Nov 2021 21:40:42 +0300 Subject: [PATCH] fix: prevent jumping when in START state --- src/fsm-transitions.js | 3 ++- test/transitions.test.js | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/fsm-transitions.js b/src/fsm-transitions.js index f8f81a9..fa3854d 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 ] }, { 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); });