Skip to content

Commit

Permalink
Bugfix for #1009.
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-suraj-kumar committed Sep 23, 2024
1 parent 4ebb8c3 commit 0a6772c
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,21 @@ function AutoHeight(userOptions: AutoHeightOptionsType = {}): AutoHeightType {
if (!container.getAttribute('style')) container.removeAttribute('style')
}

function highestInView(): number {
function highestInView(): number | null {
const { slideRegistry } = emblaApi.internalEngine()
const selectedIndexes = slideRegistry[emblaApi.selectedScrollSnap()]

if (!selectedIndexes) return null

return selectedIndexes
.map((index) => slideHeights[index])
.reduce((a, b) => Math.max(a, b), 0)
}

function setContainerHeight(): void {
const height = highestInView()
if (height === null) return

emblaApi.containerNode().style.height = `${highestInView()}px`
}

Expand Down

0 comments on commit 0a6772c

Please sign in to comment.