|
| 1 | +@use "../01-abstract/theme-json" as *; |
| 2 | +@use "m-scrollbar" as *; |
| 3 | + |
| 4 | +/** |
| 5 | + * Horizontal scroll track with mandatory snap (no Swiper). |
| 6 | + * Full-bleed track via responsive gutters; next slide peeks on the right. |
| 7 | + * |
| 8 | + * @author Cédric Andrietti |
| 9 | + * |
| 10 | + * @param $item-selector - slide items (default: direct li children) |
| 11 | + * |
| 12 | + * Custom properties (optional overrides on the scroll container, set before the include): |
| 13 | + * --horizontal-scroll-gap - flex gap (falls back to --column-gap, then theme spacing) |
| 14 | + * --horizontal-scroll-peek - visible part of the next slide (defaults to gap + xs spacing) |
| 15 | + * |
| 16 | + * Example: |
| 17 | + * |
| 18 | + * .my-track { |
| 19 | + * @include breakpoints(sm, max) { |
| 20 | + * --horizontal-scroll-gap: var(--column-gap); |
| 21 | + * @include horizontal-scroll-snap; |
| 22 | + * } |
| 23 | + * } |
| 24 | + */ |
| 25 | +@mixin horizontal-scroll-snap($item-selector: "> li") { |
| 26 | + $_horizontal-scroll-gap: var(--horizontal-scroll-gap, var(--column-gap, #{$settings-spacing-xs})); |
| 27 | + $_horizontal-scroll-peek: var(--horizontal-scroll-peek, calc(#{$_horizontal-scroll-gap} + #{$settings-spacing-xs})); |
| 28 | + |
| 29 | + display: flex; |
| 30 | + flex-wrap: nowrap; |
| 31 | + gap: #{$_horizontal-scroll-gap}; |
| 32 | + width: calc(100% + var(--responsive--gutter-left) + var(--responsive--gutter-right)); |
| 33 | + padding-inline: var(--responsive--gutter-left) var(--responsive--gutter-right); |
| 34 | + margin-inline: calc(-1 * var(--responsive--gutter-left)) calc(-1 * var(--responsive--gutter-right)); |
| 35 | + overflow-x: auto; |
| 36 | + overscroll-behavior-x: contain; |
| 37 | + scroll-snap-type: x mandatory; |
| 38 | + scroll-padding-inline: var(--responsive--gutter-left) var(--responsive--gutter-right); |
| 39 | + -webkit-overflow-scrolling: touch; |
| 40 | + |
| 41 | + @include scrollbar-invisible; |
| 42 | + |
| 43 | + #{$item-selector} { |
| 44 | + flex: 0 0 calc(100% - #{$_horizontal-scroll-peek}); |
| 45 | + min-width: 0; |
| 46 | + scroll-snap-align: start; |
| 47 | + } |
| 48 | +} |
0 commit comments