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

flex-range

v0.2.0

Published

A vanilla JavaScript range slider

Downloads

3

Readme

FlexRange

A flexible vanilla JavaScript range slider

Note: This is an experimental project. Its not recommended to use it in production.

CodePen Demo


Installation

npm install flex-range

or import from cdn: import { FlexRange } from 'https://cdn.skypack.dev/flex-range'

Usage

HTML:

<input id="slider" type="range" />

All slider options can also be set with data-attributes:

<input id="slider" type="range" data-min="0" data-max="100" data-from="10" data-to="90" />

JS:

import { FlexRange } from 'flex-range';

// initialize slider instance
const slider = new FlexRange('#slider', {
    min: 0,
    max: 100,
    from: 10,
    to: 90,
});

// update slider values
slider.update({ from: 20, to: 80 });

// listen to changes
slider.on('change', (event) => {
    console.log(event.values);
});

Note: to prevent the slider from firing the change event when calling update(), set the second argument to false (e.g. slider.update({ from: 1 }, false)).

Options:

| Name | Description | | ---- | -------------------- | | min | minimum value | | max | maximum value | | from | initial value 'from' | | to | initial value 'to' |

Methods:

| Name | Description | | -------- | -------------------------------------- | | update() | update one or more slider values | | reset() | reset the slider to its initial values | | on() | listen to events |

Events:

| Name | Description | | ------ | ------------------------------------------------------------- | | change | fires when a slider value changes | | update | fires only when the slider values get updated with update() | | reset | fires on form reset or when reset() is called |

SCSS:

@use 'flex-range';

Customize

Example for overriding variables:

@use 'flex-range' with (
    $fr-primary-color: #0150ce,
    $fr-bar-width: 0.2rem,
    $fr-handle-size: 1.25rem,
    $fr-handle-color: #0150ce,
    $fr-handle-border: none,
);

All default variables:

// general variables
$fr-primary-color: hsl(0deg, 0%, 33%) !default;

// bar variables
$fr-bar-width: 0.2rem !default;
$fr-bar-color: hsl(0deg, 0%, 80%) !default;
$fr-bar-range-color: $fr-primary-color !default;

// handle variables
$fr-handle-size: 2rem !default;
$fr-handle-color: white !default;
$fr-handle-border-color: $fr-primary-color !default;
$fr-handle-active-color: $fr-primary-color !default;
$fr-handle-border: 0.2rem solid $fr-handle-border-color !default;
$fr-handle-border-radius: 50% !default;
$fr-handle-shadow: none !default;

License

MIT