Scrub Slider

Scrub Slider is a lightweight javascript plugin that lets you display transition images with style.

Why Scrub?

- Vanilla JS with no dependencies (not even jQuery)! -

- Just 29kb dist minified. -

- Support for using multiple sliders on a page. -

- Simple configuration options -

- Soon available on NPM and Yarn.. -

Getting Started

Download

  • Download the Scrub Slider dist files from Github or from NPM or Yarn (coming soon..)

  • Include the minified Scrub js and css files in the usual fashion..

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.

Settings

Configure

You can configure your Scrub instance by passing your selector and some config parameters as an object. e.g:

    Scrub({
        target: #slider1,
        height: 500,
        handle: true,
        src: ['https://raw.github.com/Recidvst/recidvst-images/master/mustang-old-min.jpg','https://raw.github.com/Recidvst/recidvst-images/master/mustang-old-inverted-min.jpg'],
        alt: ['Image number 1 alt','Image number 2 alt']
    });

The available options are as follows:

  • Target

    Purpose: This is the item which you wish to become a Scrub slider! Pass the id or unique class of a container element.
    Type: string
    Default: null
    Required: Yes.
  • Height

    Purpose: This is the height of your Scrub instance. Defaults to 500px. Specify height in pixels.
    Type: string
    Default: 500px
    Required: No. But recommended.
  • Handle

    Purpose: This is the switch for the circular handle control on the slider's dividing line. Set to false to hide. If you want to hide the vertical bar as well, use css on '.sliding'.
    Type: bool
    Default: true
    Required: No.
  • Src

    Purpose: Alternate method of specifying slider images. Pass an array of two strings containing an img src. Left then right.
    Type: array
    Default: null
    Required: No. As long as the element you want to instantiate as a Scrub slider is an image or a div with a valid background-image style.
  • Alt

    Purpose: Add an alt tag to the slider. Pass an array of two strings describing each image. Left then right.
    Type: array
    Default: null
    Required: No.