Skip to content

Commit 6d76703

Browse files
authored
Merge pull request #38 from rtCamp/fix/carousel-loop-spacing
2 parents e0c8352 + b17f643 commit 6d76703

File tree

8 files changed

+1849
-512
lines changed

8 files changed

+1849
-512
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# [1.0.1](https://github.com/rtCamp/carousel-system-interactivity-api/compare/1.0.0...1.0.1) (2026-02-16)
2+
3+
### Bug Fixes
4+
5+
* **carousel:** resolve spacing issues in loop mode where gaps were missing between last and first slide
6+
* **carousel:** allow infinite loop in editor viewport to match frontend behavior
7+
18
# 1.0.0 (2026-02-03)
29

310

examples/data/carousel-kit.xml

Lines changed: 1814 additions & 0 deletions
Large diffs are not rendered by default.

examples/data/core-carousel.xml

Lines changed: 0 additions & 507 deletions
This file was deleted.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "carousel-kit",
3-
"version": "1.0.0",
2+
"name": "core-carousel",
3+
"version": "1.0.1",
44
"description": "Carousel block using Embla and WordPress Interactivity API",
55
"author": "rtCamp",
66
"private": true,

src/blocks/carousel/edit.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export default function Edit( {
6868
className: 'carousel-kit',
6969
dir: direction,
7070
'data-axis': axis,
71+
'data-loop': loop ? 'true' : undefined,
7172
style: {
7273
'--carousel-kit-gap': `${ attributes.slideGap }px`,
7374
'--carousel-kit-height': axis === 'y' ? height : undefined,

src/blocks/carousel/save.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export default function Save( {
5959
'aria-label': ariaLabel,
6060
dir: direction,
6161
'data-axis': axis,
62+
'data-loop': loop ? 'true' : undefined,
6263
'data-wp-interactive': 'carousel-kit/carousel',
6364
'data-wp-context': JSON.stringify( context ),
6465
'data-wp-init': 'callbacks.initCarousel', // Use init for mounting

src/blocks/carousel/styles/_core.scss

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
margin: 0;
1818
padding: 0;
1919
list-style: none;
20-
gap: 0;
2120
grid-template-columns: none;
2221
gap: var(--carousel-kit-gap, 0);
2322
}
@@ -38,11 +37,27 @@
3837
min-width: 0;
3938
box-sizing: border-box;
4039

41-
/* Reset vertical margins to align slides */
40+
/* Reset margins by default (use gap instead) */
41+
margin-inline-end: 0;
4242
margin-block-start: 0;
4343
margin-block-end: 0;
4444
}
4545

46+
/**
47+
* Fix for Embla Carousel Loop + Gap
48+
* When looping is enabled, Embla v8 doesn't support CSS 'gap'.
49+
* We switch to margin for consistent spacing in loop mode.
50+
*/
51+
:where(.core-carousel[data-loop="true"]) .embla__container,
52+
:where(.core-carousel[data-loop="true"]) .embla .wp-block-post-template {
53+
gap: 0;
54+
}
55+
56+
:where(.core-carousel[data-loop="true"]) .embla__slide,
57+
:where(.core-carousel[data-loop="true"]) .embla .wp-block-post-template li {
58+
margin-inline-end: var(--core-carousel-gap, 0);
59+
}
60+
4661
/* Vertical Axis adjustments */
4762
:where(.carousel-kit[data-axis="y"]) {
4863
display: flex;
@@ -66,3 +81,9 @@
6681
max-width: 100%;
6782
margin-inline-end: 0;
6883
}
84+
85+
/* Vertical + Loop specific */
86+
:where(.core-carousel[data-axis="y"][data-loop="true"]) .embla__slide,
87+
:where(.core-carousel[data-axis="y"][data-loop="true"]) .embla .wp-block-post-template li {
88+
margin-block-end: var(--core-carousel-gap, 0);
89+
}

src/blocks/carousel/viewport/edit.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export default function Edit( {
8181
const options = carouselOptions as any;
8282

8383
embla = EmblaCarousel( emblaRef.current!, {
84-
loop: false,
84+
loop: options?.loop ?? false,
8585
dragFree: options?.dragFree ?? false,
8686
containScroll: options?.containScroll || 'trimSnaps',
8787
axis: options?.axis || 'x',

0 commit comments

Comments
 (0)