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

When CSS zoom is used, the slides in the carousel does not scroll correctly #1331

Open
2 tasks done
petertflem opened this issue Sep 9, 2024 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@petertflem
Copy link

petertflem commented Sep 9, 2024

Checks

Version

v4.1.3

Description

We're using the CSS zoom property, and it causes the carousel to calculate the incorrect distance to move the slides.

It can be reproduced on the splidejs homepage as well, here I added zoom: 1.25 on the body tag, and transitioned the carousel to the second slide. The third slide should not be visible here, but it is.
image

I attempted a work around using a custom transition to adjust the value it uses to translate the slides:

        // Converts the index to the position
        const destination = Move.toPosition(index, true);
 
        ...

        let zoomDelta = 0;

        if (viewportWidth >= 1950) {
            zoomDelta = destination * 0.1667;
        } else if (viewportWidth >= 1700) {
            zoomDelta = destination * 0.115;
        } else if (viewportWidth >= 1550) {
            zoomDelta = destination * 0.04764;
        }

        ...

        // Moves the carousel to the destination.
        Move.translate(destination - zoomDelta);
        
        ...

But, it turned out what worked for Chrome did not work in Firefox. In Safari, it seems to work out of the box, so at least part of the issue might be how different browsers handle the zoom.

I tried using the same reproduction steps on the carousel page in shadcdn, and I can't see the same problem in Chrome.

Reproduction Link

No response

Steps to Reproduce

  1. On the splidejs home page, add zoom: 1.25 to the body tag
  2. Click next slide on the first carousel
  3. The third slide is now visible. Without the zoom set, it is not visible.

Expected Behaviour

The third slide should not be visible.

@petertflem petertflem added the bug Something isn't working label Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant