npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

scrub-slider

v2.1.2

Published

A lightweight javascript library that lets you 'scrub' transition between two images with style.

Downloads

28

Readme

npm npm license

Scrub Slider

A lightweight javascript library that lets you 'scrub' transition between two images with style.

Demo Page

Install

  • Install the package from NPM or Yarn.
  • Or download manually from Github.
npm install scrub-slider

JS

Either import the JS as a module:

import Scrub from "scrub-slider";

Or consume the module as UMD/IIFE

<script src="./scrub.iife.js"></script>

CSS

Either import the CSS into your JS/CSS:

import "scrub-slider/dist/scrub.css";
@import "scrub-slider/dist/scrub.css";

Or include it the old fashioned way:

<link href="./scrub.css" rel="stylesheet" />

Usage

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 html
    • any tag (empty), with image specified with the src config property
  • Edit the css provided to add your own styling e.g. to the handle
  • The container should have a width.

Configure

You can configure your Scrub instance by passing your selector and some config parameters as an object. 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 style this differently, add your own 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 with valid src property or a div with a valid background-image property.

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.

Example

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"],
});