rcbyr / keen-slider

The HTML touch slider carousel with the most native feeling you will get.
https://keen-slider.io/
MIT License
4.57k stars 210 forks source link

Q: Scale active slide #341

Closed anstapol closed 1 year ago

anstapol commented 1 year ago

Hey guys, first of all thanks for the amazing library, it's really simple and awesome. However I'm struggling when trying to achieve next effect:

Screenshot 2023-06-18 at 11 56 32

Effect description:

I've obviously tried all css variations but no luck. One example:

    .keen-slider {
        overflow-x: hidden !important;
        overflow-y: visible !important;
    }

    .keen-slider__slide {
        transform-origin: left center;
        overflow: visible !important;
        z-index: 0;
    }

    .keen-slider__slide.active {
        z-index: 10;
    }

    .keen-slider__slide.active img {
        transform: scale(1.25);
    }

As you may know specifying two axis overflows doesn't work very well in css

But a scrollbar appears and only overflow: visible !important fixes the issue with a drawback of showing all the slides horizontally which is not ideal:

Screenshot 2023-06-18 at 11 59 49

So I was thinking maybe a custom plugin would help here? Would appreciate any suggestions, Cheers.

anstapol commented 1 year ago

If anyone faces same difficulties I ended up adding vertical padding to the parent, making all overflows visible and adding an additional wrapper with overflow-x: hidden.