Scrub Slider
A lightweight javascript library that lets you 'scrub' transition between two images with style.
Why Scrub?
- Vanilla JS with no dependencies -
- Only around 10kb for both JS and CSS -
- Support for using multiple sliders on a page -
- Simple configuration options and multiple implementation methods -
- IE9+ supported -
- Available on NPM and Yarn -
Getting Started
Download
- Install the package (or download the dist files manually) from Github or from NPM or Yarn
- Include the js and css in your application by either importing the module or using the UMD/IIFE output via a script tag.
Initiate
- Scrub needs to be passed a containing element plus two images to work.
- Initiate a Scrub instance by calling Scrub() with a valid selector (of the parent element). This is best as an ID but a unique class is fine too.
- If you wish to configure your slider, pass Scrub() an object with config options (see below).
-
You have a choice for how you want to pass the two images:
- `img` with src properties
- `div` with background-image set on the tag
- use a different tag and pass the src via config - Edit the css provided to add your own styling e.g. to Zzthe handle
- The container should have a width.