explaingit

thebird/swipe

6,755JavaScriptAudience · developerComplexity · 1/5LicenseSetup · easy

TLDR

A lightweight JavaScript library that turns any set of HTML elements into a touch-friendly slider with swipe gestures, auto-advance, and looping, used by CNN, Airbnb, and Craigslist.

Mindmap

mindmap
  root((swipe))
    What it does
      Touch sliders
      Swipe gestures
      Auto-advance
    Features
      Loop endlessly
      Custom speed
      Start position
    API
      Next and prev
      Jump to slide
      Slide callbacks
    Compatibility
      All major browsers
      IE7 fallback
      Mobile and desktop
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Add a swipeable image carousel to a mobile website without a heavy framework.

USE CASE 2

Build a touch-friendly slideshow that auto-advances on a timer and loops endlessly.

USE CASE 3

Control a content slider programmatically with next, previous, and jump-to-slide buttons.

Tech stack

JavaScriptCSS

Getting it running

Difficulty · easy Time to first run · 5min
MIT-licensed, use freely for any purpose, including commercial projects, as long as you keep the copyright notice.

In plain English

Swipe is a small JavaScript library that turns a set of HTML elements into a touch-friendly slider. You wrap your content inside two nested containers, point Swipe at the outer one, and it handles all the swiping behavior, including touch gestures on phones and tablets, arrow-based transitions on desktop, and auto-advancing if you want a slideshow effect. Setup requires adding a few lines of CSS to control how the containers sit on the page, then calling the Swipe function once after the page has loaded. From that point the library manages sliding between items automatically when a user swipes or when your own code triggers a transition. Options include setting which slide appears first, controlling how fast transitions animate, enabling an automatic slideshow with a custom interval, and looping endlessly so there is no hard stop at the first or last item. The library also exposes a small API for controlling the slider from your own scripts: you can move to the previous or next slide, jump to a specific position, or ask for the current position and total slide count. Two callback hooks let you run custom code whenever a slide changes and again when the transition animation finishes. Swipe works in all major browsers and falls back gracefully in older environments like IE7 by detecting whether CSS transitions and touch events are available and choosing the right animation method for each case. The README notes that CNN, Craigslist, Airbnb, and the NHL have used it. The project is released under the MIT license. The README is brief and focused entirely on usage, so there is no deeper documentation on internals or contribution guidelines.

Copy-paste prompts

Prompt 1
Help me integrate the Swipe library into my HTML page to create a touch-friendly image carousel that auto-advances every 3 seconds and loops back to the start.
Prompt 2
Using the Swipe library API, write JavaScript that adds previous and next arrow buttons to control the slider outside the library.
Prompt 3
Show me how to set up Swipe so the slider starts on the third slide and fires a custom callback each time the slide changes.
Open on GitHub → Explain another repo

← thebird on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.