0.2.0 • Published 4 years ago

@danchitnis/simple-slider v0.2.0

Weekly downloads
18
License
MIT
Repository
github
Last release
4 years ago

simple-slider

A simple range slider based on vanilla HTML, CSS and JS with no dependencies. Features include:

  • Cross-browser compatibility using vanilla Javascript and CSS
  • Simple constructor and developer friendly
  • Single file library with no dependency, written in Typescript and compatible with ES6
  • Can be bundled with modern tools such as RollupJS
  • Touch enabled for touchscreen devices
  • Responsive to real-time layout change

Example

Initialization

const slider = new SimpleSlider("slider", 0, 100, 0);

handle the update event

slider.addEventListener("update", e => {
  pValue.innerHTML = slider.value.toString() + "%";
});

Redraw the slider upon window resize

window.addEventListener("resize", () => {
  slider.resize();
});

JSfiddle Example

CodePen Example

Edit Simple Slider

Webkit (i.e. Safari & iPhone)

Add the following polyfill before your script to have support for Webkit. This also includes Chrome on iPhone since it is based on Webkit.

<script src="https://unpkg.com/@ungap/event-target"></script>

This package will automatically detect if Event-Target is present in the browser.

API documentation

See here 🧾

Contributions

inspired by noUiSlider

0.2.0

4 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago