improved carousel layout

This commit is contained in:
Oliver Walters committed 2026-11-12 05:58:15 +00:00
1 parent e74b2ff1c0
commit 92760aa226
3 files changed
+39 -10

No files matched your search

+23 -9
View File
@@ -11,22 +11,36 @@
</div>
<script>
document.addEventListener( 'DOMContentLoaded', function () {
// With navigation.instant, page content is swapped in without a new
// DOMContentLoaded event, so mount immediately if the document has loaded
(function () {
function mountCarousel() {
new Splide(
'.splide', {
type: 'loop',
perPage: {{ per_page }},
autoplay: true,
pagination: false,
// cover: true,
// autoWidth: true,
height: '25rem',
// Each slide is as wide as its image, so that all images
// are scaled to the same height (set in extra.css)
autoWidth: true,
height: '{{ height | default("14rem") }}',
breakpoints: {
// Narrow screens (e.g. mobile)
700: {
height: '{{ mobile_height | default("8rem") }}',
},
},
gap: '1rem',
focus: 'center',
padding: {
left: '5rem',
right: '5rem',
}
}
).mount();
} );
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', mountCarousel);
} else {
mountCarousel();
}
})();
</script>
+1 -1
View File
@@ -2,7 +2,7 @@
title: InvenTree Mobile App
---
{% with directory="appgallery", per_page=2 %}
{% with directory="appgallery", per_page=2, height="25rem", mobile_height="25rem" %}
{% include "carousel.html" %}
{% endwith %}
+15
View File
@@ -183,3 +183,18 @@ div:nth-of-type(1) p:not(.admonition-title) {
.api-method-patch { background-color: #9c36b5; }
.api-method-delete { background-color: #c92a2a; }
.api-method-head, .api-method-options { background-color: #495057; }
/* Image carousel: scale every image to the slide height, keeping aspect ratio */
.splide__slide {
display: flex;
align-items: center;
justify-content: center;
}
.splide__slide img {
height: 100%;
width: auto;
/* Very wide images shrink to fit the carousel on narrow screens */
max-width: calc(100vw - 2rem);
object-fit: contain;
}