Skip to content

Commit

Permalink
supporting entry-crossing range name (#6)
Browse files Browse the repository at this point in the history
* supporting entry-crossing range name

* cleanup

* cleanup
  • Loading branch information
ameerabuf authored Aug 12, 2024
1 parent 7ad9fe2 commit 8728134
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dist/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ function transformRangeToPosition (range, viewportSize, rect) {
startPosition = start - viewportSize;
duration = Math.min(viewportSize, height);
}
else if (name === 'entry-crossing') {
startPosition = start - viewportSize;
duration = height;
}
else if (name === 'contain') {
startPosition = Math.min(end - viewportSize, start);
// it's either VH - height OR height - VH; so it boils down to just the absolute value of that
Expand Down Expand Up @@ -225,6 +229,7 @@ function computeStickinessIntoFullRange(offsetTree, absoluteStartOffset, absolut
* @param {number} viewportSize
* @param {boolean} isHorizontal
* @param {AbsoluteOffsetContext} absoluteOffsetContext
* @param {Array<{element: HTMLElement, offset: number, sticky: {start?: number, end?: number}}>} offsetTree
* @return {ScrollScene}
*/
function transformSceneRangesToOffsets (scene, rect, viewportSize, isHorizontal, absoluteOffsetContext, offsetTree) {
Expand Down
4 changes: 4 additions & 0 deletions src/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ function transformRangeToPosition (range, viewportSize, rect) {
startPosition = start - viewportSize;
duration = Math.min(viewportSize, height);
}
else if (name === 'entry-crossing') {
startPosition = start - viewportSize;
duration = height;
}
else if (name === 'contain') {
startPosition = Math.min(end - viewportSize, start);
// it's either VH - height OR height - VH; so it boils down to just the absolute value of that
Expand Down

0 comments on commit 8728134

Please sign in to comment.