GPU-accelerated smooth animations with stunning transition effects
GPU-accelerated rendering with WebGL delivers 60fps smooth animations
20+ built-in effects with custom shader support for creative transitions
Mobile-friendly with touch gesture support for seamless user experience
Native components for React, Vue, and Svelte frameworks
Create unique effects with custom GLSL shaders
Automatic Canvas 2D fallback for non-WebGL environments
npm install webgl-carousel
yarn add webgl-carousel
<script src="https://unpkg.com/webgl-carousel/dist/webgl-carousel.umd.js"></script>
import { WebGLCarousel } from 'webgl-carousel';
const carousel = new WebGLCarousel.WebGLCarousel({
container: '#carousel',
images: [
'path/to/image1.jpg',
'path/to/image2.jpg',
'path/to/image3.jpg'
],
effect: 'fade',
autoplay: true,
transitionDuration: 2000
});
import { ReactCarousel } from 'webgl-carousel/react';
function App() {
const images = [
'path/to/image1.jpg',
'path/to/image2.jpg',
'path/to/image3.jpg'
];
return (
<ReactCarousel
images={images}
effect="slideLeft"
autoplay
transitionDuration={1500}
style={{ width: '100%', height: '400px' }}
/>
);
}
<template>
<VueCarousel
:images="images"
effect="wave"
:autoplay="true"
:transition-duration="2000"
style="width: 100%; height: 400px;"
/>
</template>
<script setup>
import { VueCarousel } from 'webgl-carousel/vue';
const images = [
'path/to/image1.jpg',
'path/to/image2.jpg',
'path/to/image3.jpg'
];
</script>
<script>
import { SvelteCarousel } from 'webgl-carousel/svelte';
const images = [
'path/to/image1.jpg',
'path/to/image2.jpg',
'path/to/image3.jpg'
];
</script>
<SvelteCarousel
{images}
effect="flip"
autoplay={true}
transitionDuration={1800}
style="width: 100%; height: 400px;"
/>
Simple fade transition
Horizontal slide transitions
Vertical slide transitions
3D rotation effects
Wave animation effect
Lens distortion effect
Dissolve transition
Pixelated dissolve effect
Circular reveal transition
Morphing effect
Digital glitch effect
Option | Type | Default | Description |
---|---|---|---|
container | string | HTMLElement | required | Container element or selector |
images | string[] | [] | Array of image URLs |
effect | string | 'fade' | Transition effect name |
autoplay | boolean | false | Enable automatic playback |
interval | number | 3000 | Autoplay interval in milliseconds |
transitionDuration | number | 1000 | Transition duration in milliseconds |
loop | boolean | true | Loop back to first image after last |
showControls | boolean | true | Show navigation controls |
showIndicators | boolean | true | Show position indicators |
// Navigate to next image
carousel.next();
// Navigate to previous image
carousel.previous();
// Jump to specific index
carousel.goTo(2);
// Start/stop autoplay
carousel.play();
carousel.pause();
// Change effect
carousel.setEffect('wave');
// Handle resize
carousel.resize();
// Cleanup
carousel.dispose();
// Image change event
carousel.on('change', (index) => {
console.log('Current image:', index);
});
// Transition start event
carousel.on('transitionStart', (from, to) => {
console.log(`Transitioning from ${from} to ${to}`);
});
// Transition end event
carousel.on('transitionEnd', (index) => {
console.log('Transition completed:', index);
});
// Error event
carousel.on('error', (error) => {
console.error('Carousel error:', error);
});
Create unique transition effects using custom GLSL shaders.
import { createCustomEffect } from 'webgl-carousel';
const myEffect = createCustomEffect(
'myCustomEffect',
// Vertex shader (optional)
`
attribute vec2 aPosition;
attribute vec2 aTexCoord;
varying vec2 vTexCoord;
void main() {
gl_Position = vec4(aPosition, 0.0, 1.0);
vTexCoord = aTexCoord;
}
`,
// Fragment shader
`
precision mediump float;
uniform sampler2D uTexture0;
uniform sampler2D uTexture1;
uniform float uProgress;
uniform vec2 uResolution;
varying vec2 vTexCoord;
void main() {
vec2 uv = vTexCoord;
// Custom effect logic
float wave = sin(uv.y * 10.0 + uProgress * 3.14159) * 0.05;
vec2 distortedUV = vec2(uv.x + wave * uProgress, uv.y);
vec4 color0 = texture2D(uTexture0, distortedUV);
vec4 color1 = texture2D(uTexture1, uv);
gl_FragColor = mix(color0, color1, uProgress);
}
`
);
// Register custom effect
carousel.registerEffect(myEffect);
carousel.setEffect('myCustomEffect');