diff --git a/src/fsm-transitions.js b/src/fsm-transitions.js index 266e099..6d79909 100644 --- a/src/fsm-transitions.js +++ b/src/fsm-transitions.js @@ -6,7 +6,7 @@ export default { to: states.FINISH, when: (d) => [ d.isSideInnerFitsPath === true, - d.viewportTop + d.sideInnerHeight >= d.finishPoint + d.viewportTop + d.sideInnerHeight > d.finishPoint ] }, { @@ -14,7 +14,7 @@ export default { when: (d) => [ d.isSideInnerFitsPath === true, d.isSideInnerFitsViewport === false, - d.viewportBottom >= d.sideInnerBottom + d.bottomSpacing + d.viewportBottom > d.sideInnerBottom + d.bottomSpacing ], }, { @@ -22,7 +22,7 @@ export default { when: (d) => [ d.isSideInnerFitsPath === true, d.isSideInnerFitsViewport === true, - d.viewportTop >= d.startPoint - d.topSpacing + d.viewportTop > d.startPoint - d.topSpacing ] } ], @@ -38,7 +38,7 @@ export default { }, { to: states.FINISH, - when: (d) => [d.sideInnerBottom >= d.finishPoint] + when: (d) => [d.sideInnerBottom > d.finishPoint] }, { to: states.UNFIXED, @@ -54,9 +54,20 @@ export default { to: states.START, when: (d) => [d.isSideInnerFitsPath === false], }, + { + to: states.START, + when: (d) => [d.viewportTop <= d.startPoint - d.topSpacing] + }, + { + to: states.FINISH, + when: (d) => [d.viewportTop + d.sideInnerHeight > d.finishPoint] + }, { to: states.TOP_FIXED, - when: (d) => [d.viewportTop <= d.sideInnerTop - d.topSpacing] + when: (d) => [ + d.scrollDirection === 'up', + d.viewportTop <= d.sideInnerTop - d.topSpacing + ] }, { to: states.TOP_FIXED, @@ -69,7 +80,7 @@ export default { to: states.BOTTOM_FIXED, when: (d) => [ d.isSideInnerFitsViewport === false, - d.viewportBottom >= d.sideInnerBottom + d.bottomSpacing + d.viewportBottom > d.sideInnerBottom + d.bottomSpacing ] } ], @@ -79,6 +90,13 @@ export default { to: states.START, when: (d) => [d.isSideInnerFitsPath === false], }, + { + to: states.START, + when: (d) => [ + d.isSideInnerFitsPath === true, + d.sideInnerTop <= d.startPoint - d.topSpacing + ] + }, { to: states.UNFIXED, when: (d) => [d.scrollDirection === 'up'] @@ -89,7 +107,7 @@ export default { }, { to: states.FINISH, - when: (d) => [d.sideInnerBottom >= d.finishPoint] + when: (d) => [d.sideInnerBottom > d.finishPoint] } ], @@ -98,11 +116,15 @@ export default { to: states.START, when: (d) => [d.isSideInnerFitsPath === false], }, + { + to: states.START, + when: (d) => [d.viewportTop <= d.startPoint - d.topSpacing] + }, { to: states.BOTTOM_FIXED, when: (d) => [ d.sideInnerBottom + d.bottomSpacing <= d.finishPoint, - d.viewportBottom <= d.finishPoint + d.viewportBottom < d.finishPoint ] }, { diff --git a/src/index.js b/src/index.js index de49112..4257f3e 100644 --- a/src/index.js +++ b/src/index.js @@ -34,7 +34,6 @@ function FloatSidebar(options) { updateSideOuterHeight(prevDimensions, dimensions); }, - { $viewport, $sideOuter,