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

[Bug]: Loop: true causes layout shift #970

Closed
4 of 15 tasks
Verdant31 opened this issue Aug 9, 2024 · 2 comments
Closed
4 of 15 tasks

[Bug]: Loop: true causes layout shift #970

Verdant31 opened this issue Aug 9, 2024 · 2 comments
Assignees
Labels
duplicate This issue or pull request already exists

Comments

@Verdant31
Copy link

Which variants of Embla Carousel are you using?

  • embla-carousel (Core)
  • embla-carousel-react
  • embla-carousel-vue
  • embla-carousel-svelte
  • embla-carousel-autoplay
  • embla-carousel-auto-scroll
  • embla-carousel-solid
  • embla-carousel-auto-height
  • embla-carousel-class-names
  • embla-carousel-fade
  • embla-carousel-docs (Documentation)
  • embla-carousel-docs (Generator)

Steps to reproduce

The bug occurs when I pass "loop" as true in carousel options, when loading the page for the first time the layout breaks trying to align the slides

Expected Behavior

HTML should not break when loop is true

Additional Context

I saw the documentation saying that if it doesnt have enough slides will back to loop:false but i tried with a lot slides quantities and all of than gave the layout shift.

Demonstration:

Gravando.2024-08-09.151825.mp4

Im actually using shadcn to do this but I THINK this problem is related to embla specifically (if its not the case, just close the issue)

'use client'
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
import {
  Carousel,
  CarouselContent,
  CarouselItem,
} from '@/components/ui/carousel'

export default function MyComponent() {
  return (
    <Carousel
      opts={{
        loop: true,
      }}
      className="w-full  mx-auto"
    >
      <CarouselContent className="-ml-4">
        {Array.from({ length: 5 }).map((_, index) => (
          <CarouselItem key={index} className="pl-4 basis-[260px]">
            <Card className="bg-background border-zinc-800">
              <CardHeader>
                <CardTitle className="text-md font-normal text-white">
                  Total em FIIs
                </CardTitle>
              </CardHeader>
              <CardContent className="text-white pt-2 text-lg font-semibold tracking-wide">
                <p>R$25.000,50</p>
              </CardContent>
              <CardContent className="text-white text-[12px] font-thin tracking-wide">
                <p>+6% from initial value</p>
              </CardContent>
            </Card>
          </CarouselItem>
        ))}
      </CarouselContent>
    </Carousel>
  )
}

What browsers are you seeing the problem on?

Chrome

Version

8.1.8

CodeSandbox

No response

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues
  • I agree to follow this project's Contributing Guidelines for bug reports
@Verdant31 Verdant31 added the bug Something isn't working label Aug 9, 2024
@davidjerleke
Copy link
Owner

davidjerleke commented Aug 9, 2024

@Verdant31 Embla doesn’t support SSR yet but it’s on the roadmap:

See this comment for a workaround:

Did you search for existing issues before creating this? If not, this is a friendly reminder that please make an effort before creating duplicate issues. Duplicate of:

@davidjerleke davidjerleke added duplicate This issue or pull request already exists and removed bug Something isn't working labels Aug 9, 2024
@Verdant31
Copy link
Author

That was my bad, sorry.
Thanks for you time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants