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

Account for insets when comparing size of subject to size of scrollport/view progress visibility range #210

Merged
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
8 changes: 5 additions & 3 deletions src/scroll-timeline-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,9 @@ export function calculateRange(phase, sourceMeasurements, subjectMeasurements, a

let startOffset = undefined;
let endOffset = undefined;
const targetIsTallerThanContainer = viewSize > sizes.containerSize ? true : false;
// Take inset into account when determining the scrollport size
const adjustedScrollportSize = sizes.containerSize - inset.start - inset.end;
const subjectIsLargerThanScrollport = viewSize > adjustedScrollportSize;

switch(phase) {
case 'cover':
Expand All @@ -694,11 +696,11 @@ export function calculateRange(phase, sourceMeasurements, subjectMeasurements, a

case 'entry-crossing':
startOffset = coverStartOffset;
endOffset = targetIsTallerThanContainer ? containEndOffset : containStartOffset;
endOffset = subjectIsLargerThanScrollport ? containEndOffset : containStartOffset;
break;

case 'exit-crossing':
startOffset = targetIsTallerThanContainer ? containStartOffset : containEndOffset;
startOffset = subjectIsLargerThanScrollport ? containStartOffset : containEndOffset;
endOffset = coverEndOffset;
break;
}
Expand Down