contao-components/swipe
Adds touch-enabled swipe/slider support for Contao via a reusable component. Provides an easy way to integrate swipe gestures and responsive carousels into frontend templates, improving navigation on mobile and modern browsers with minimal setup.
swipe package is a lightweight JavaScript-based touch slider with a dot menu, designed for mobile-first interactions. It fits well in architectures requiring modular UI components (e.g., carousels, image galleries, or feature highlights) without heavy dependencies.<script> tags (less ideal for maintainability).<!-- Blade Template -->
<div id="my-slider" data-swipe='{"dots": true}'></div>
<script src="https://cdn.jsdelivr.net/npm/swipe@latest/dist/swipe.min.js"></script>
<script>new Swipe(document.getElementById('my-slider'));</script>
npm install @contao-components/swipe
Configure Vite/Laravel Mix to import and bundle:
// vite.config.js
import { defineConfig } from 'vite';
export default defineConfig({
build: {
rollupOptions: {
input: {
swipe: './resources/js/swipe.js', // Custom entry point
},
},
},
});
// routes/api.php
Route::get('/slider-items', [SliderController::class, 'index']);
fetch('/api/slider-items')
.then(response => response.json())
.then(items => {
document.getElementById('slider-container').innerHTML = items.map(...).join('');
new Swipe(document.getElementById('slider'));
});
data-swipe attributes) for non-JS team members.Cache::remember).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| JS bundle fails to load | Slider non-functional | Add fallback UI (e.g., static image grid). |
| Touch events misfire | Poor UX on mobile | Test on target devices; add desktop controls. |
| jQuery conflict | Slider breaks | Use ES6 module version; audit other JS deps. |
| Dynamic content fetch fails | Empty slider | Implement graceful degradation (e.g., skeleton loader). |
| Package abandonment | Unmaintained code | Fork or migrate to alternative (e.g., Swiper). |
data-swipe attributes.How can I help you explore Laravel packages today?