Warp Slider

A smooth, infinite slider with dynamic warp distortion and momentum based scrolling.

Installation

pnpm dlx shadcn@latest add https://atlasui.dev/r/warp-slider-html.json

Usage

Define a section with class="slider" in your HTML file. Add a div with class="slide-info" inside the section to display the slide title and count.

<section class="slider">
  <div class="slide-info">
    <p id="slide-title"></p>
    <p id="slide-count"></p>
  </div>
</section>

In your script.js file, define your slides array with name and image URL.

const slides = [
  {
    name: "Slide 1",
    img: "/image-url",
  },
  {
    name: "Slide 2",
    img: "/image-url",
  },
];

Examples

Horizontal

Update the orientation property in the config object to "horizontal".

const config = {
  orientation: "horizontal",
  ...
};

Configuration

For the HTML version, config is present inside the script.js file instead of using data attributes.

OptionTypeDefaultDescription
slides{ name: string; img: string }[]-Array of slide objects containing a name and image img URL
OptionTypeDefaultDescription
config.orientation"vertical" | "horizontal""vertical"Orientation of the slider
config.minHeightnumber1Minimum height of each slide (image)
config.maxHeightnumber1.5Maximum height of each slide (image)
config.aspectRationumber1.5Aspect ratio of slides (width / height)
config.gapnumber0.05Gap between slides
config.smoothingnumber0.05General smoothing factor for motion
config.distortionStrengthnumber2.5Strength of the warp/distortion effect
config.distortionSmoothingnumber0.1Smoothness of distortion transitions
config.momentumFrictionnumber0.95Friction applied to momentum
config.momentumThresholdnumber0.001Minimum threshold to trigger momentum
config.wheelSpeednumber0.01Scroll wheel sensitivity
config.wheelMaxnumber150Maximum wheel velocity
config.dragSpeednumber0.01Drag interaction speed
config.dragMomentumnumber0.01Momentum applied after dragging
config.touchSpeednumber0.01Touch swipe sensitivity
config.touchMomentumnumber0.1Momentum applied after touch interaction