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 10.5 kb to be imported -
- 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 and two image objects.
- 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).
- The container should have a width. You have a choice for the two image children -> divs with background-images or imgs with src set are preferred, but you can also use a different tag and pass the src via config.