Skip to content

Commit

Permalink
Merge pull request #477 from davidjerleke/bug/#472
Browse files Browse the repository at this point in the history
Bugfix #472
  • Loading branch information
davidjerleke authored May 24, 2023
2 parents d67b207 + d39edc0 commit 749c87d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/embla-carousel/src/components/ScrollContain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function ScrollContain(
containScroll: ScrollContainOptionType,
): ScrollContainType {
const scrollBounds = Limit(-contentSize + viewSize, snapsAligned[0])
const snapsBounded = snapsAligned.map(scrollBounds.constrain)
const snapsBounded = measureBounded()
const snapsContained = measureContained()

function findDuplicates(): LimitType {
Expand All @@ -25,6 +25,12 @@ export function ScrollContain(
return Limit(min, max)
}

function measureBounded(): number[] {
return snapsAligned
.map(scrollBounds.constrain)
.map((scrollBound) => parseFloat(scrollBound.toFixed(3)))
}

function measureContained(): number[] {
if (contentSize <= viewSize) return [scrollBounds.max]
if (containScroll === 'keepSnaps') return snapsBounded
Expand Down

0 comments on commit 749c87d

Please sign in to comment.