Replies: 4 comments 7 replies
-
Bump |
Beta Was this translation helpful? Give feedback.
-
Hi! I think I think I found something with css and java script, here my code:
} );`
} #materiel .splide #carousel-heading { } .splide__list .splide__slide img { .splide__slide{ } .splide__slide.is-active{ } .splide .splide__track .splide__list {
|
Beta Was this translation helpful? Give feedback.
-
It's the first time I make an codepen, hope it will work :) |
Beta Was this translation helpful? Give feedback.
-
Likely too late to help, but if someone else finds this; I had 1:1 same problem. I solved it like this. Downside - I can't animate it nicely yet, though I am sure it's doable with careful calculation / timing of the events and animation duration. But it's janky. /**
* Handle move start - change widths and refresh layout
* @param {object} slider - The Splide slider instance
* @param {number} newIndex - Index of the new slide
* @param {number} prevIndex - Index of the previous slide
*/
export const handleMoveStart = (slider, newIndex, prevIndex) => {
const prevSlide = slider.Components.Slides.getAt(prevIndex);
const newSlide = slider.Components.Slides.getAt(newIndex);
// Reset previous slide width
if (prevSlide) {
prevSlide.slide.classList.remove('is-enlarged');
}
// Set new slide width
if (newSlide) {
newSlide.slide.classList.add('is-enlarged');
}
};
/**
* Enlarge the active slide
* @param {object} slider - The Splide slider instance
*/
export const enlargeActiveSlide = (slider) => {
const activeSlide = slider.Components.Slides.getAt(slider.index);
if (activeSlide) {
activeSlide.slide.classList.add('is-enlarged');
}
};
/**
* Setup event listeners for post-type carousels
* @param {object} slider - The Splide slider instance
* @param {string} type - Carousel type
*/
export const setupPostCarouselEvents = (slider, type) => {
if (type === 'post') {
slider.on('mounted', () => {
enlargeActiveSlide(slider);
});
slider.on('move', (newIndex, prevIndex) => {
handleMoveStart(slider, newIndex, prevIndex);
});
}
}; How my slider config looks like: const baseConfig = {
arrows: showArrows,
autoHeight: true,
autoWidth: true,
autoplay: false,
drag: false,
easing: 'cubic-bezier(0.4, 0, 0.2, 1)',
gap: '2.5rem',
pagination: paginationType === 'dots',
perMove: 1,
perPage: 1,
rewind: false,
padding: 0,
focus: 'first',
type: 'slide',
}; And then in CSS .with-enlarged {
& .carousel-item {
--carousel-item-width: 620px;
margin-left: 0;
width: var(--carousel-item-width, 100%);
&.is-enlarged {
--carousel-item-width: 840px;
}
}
& .splide__list {
align-items: flex-end;
}
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Does Splide have a set of options, or are there styles I could use that would allow the active slide to be wider than the rest of the slides while maintaining the slider's
perPage
amount?On transition, the next active slide would grow and the previous active slide would shrink.
Beta Was this translation helpful? Give feedback.
All reactions