Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions packages/embla-carousel/src/components/EmblaCarousel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,20 @@ function EmblaCarousel(
if (!options.active) return

if (!isSsr && ownerWindow) {
engine.resizeHandler.init(ownerWindow)
const containerVisible = container.offsetParent

engine.translate.to(engine.location)
engine.scrollOptimizer.optimize(true)
if (engine.options.loop) engine.slideLooper.loop()

engine.animation.init(ownerWindow)
engine.resizeHandler.init(ownerWindow)
engine.slidesInView.init(ownerWindow)
engine.slidesHandler.init(ownerWindow)
engine.slideFocus.init(ownerWindow)
engine.eventHandler.init(self)

if (container.offsetParent && slides.length) {
if (containerVisible && slides.length) {
engine.dragHandler.init(ownerWindow)
}
}
Expand Down
5 changes: 3 additions & 2 deletions packages/embla-carousel/src/components/NodeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,13 @@ export function NodeHandler(root: HTMLElement): NodeHandlerType {

const containerStyle = root ? container.style : { transform: '' }
const previousTransform = containerStyle.transform
containerStyle.transform = 'none'
const needsReset = previousTransform && previousTransform !== 'none'
if (needsReset) containerStyle.transform = 'none'

const containerRect = getRect(container)
const slideRects = slides.map(getRect)

containerStyle.transform = previousTransform
if (needsReset) containerStyle.transform = previousTransform
rects = { containerRect, slideRects }
return rects
}
Expand Down