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

slider-fs-jq

v1.1.3

Published

[Demo page](https://sodiqit.github.io/FSDSlider/)

Downloads

17

Readme

FSDSlider

Demo page

Table of contents

  1. Quick start
  2. Config 2.1 Options 2.2 Methods
  3. Building and testing
  4. Architecture

1. Quick start

  1. Install plugin via npm:
npm install slider-fs-jq
  1. Import JQuery and plugin in your project:
import $ from 'jquery';
import 'slider-fs-jq';
  1. Initialize plugin:
<div class="my-selector"></div>
$('.my-selector').slider(); // Init slider with default options

or if you want to init slider with options - invoke slider with one parameter which contains options

$('.my-selector').slider({
  // options
});

2. Config

2.1 Options

A brief description of options:

| Option name | Type | Default Value | Description | ------------- |:---------------------:| :-------------:| ----------| | min | number | 0 | set minimum value for slider | | max | number | 100 | set maximum value for slider | | step | number | 1 | the number by which slider value will be increased | | firstValue | number | 0 | value of left handle | | secondValue | number | 100 | value of right handle | | isHorizontal | boolean | true | set the orientation slider | | showBubbles | boolean | true | show/hide suggestions above handles | | showScale | boolean | false | show/hide scale below slider | | hasRange | boolean | false | set two handles in range | | multiplier | number | 1 | the value by which will be increase step scale | | customValues | boolean | false | set custom values for slider | | values | (number l string)[] | null | array of custom values for slider | | autofix | boolean | false | enable/disable autofix scale units | | fixConfig | object | { distance: 45, count: null} | config for autofix, distance - is need distance between two neighbor units, count - need count unit |

Full description for options:

isHorizontal

This option set orientation of slider.

$('.my-selector').slider({
  isHorizontal: false
});

Output: alt text

showBubbles

This option show/hide suggestions above handles.

$('.my-selector').slider({
  showBubbles: true
});

Output: alt text

showScale

This option show/hide scale below slider.

$('.my-selector').slider({
  showScale: true
});

Output: alt text

hasRange

This option set two handles in range.

$('.my-selector').slider({
  hasRange: true
});

Output: alt text

Important! If you define the range, program use only firstValue and secondValue, value isn't used and backward.

multiplier

This option set number bu which increase step scale. In plugin logic calculate scale - (max - min) / step. Let's say we init plugin without this option:

$('.my-selector').slider({
  showScale: true
});

We will get it: alt text

Not good, isn't it?

If we init slider with multiplier:

$('.my-selector').slider({
  showScale: true,
  multiplier: 10
});

At this time, we will get: alt text

That's much better!

customValues & values

This options set custom values for slider.

$('.my-selector').slider({
  customValues: true,
  values: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
  showScale: true
});

Output: alt text

Important! With options must be defined together. Otherwise, will be throw error. And values been index of arr. Example, in this slider value = 0.

2.2 Methods

update

This method allows to update options in slider and rerender him.

const slider = $('.my-selector').slider({
  min: -100,
  max: 200,
});

slider.update({
  min: 200,
  max: 1000,
  step: 100,
});

getOptions

This method return current options. Example:

const slider = $('.my-selector').slider();
const sliderOptions = slider.getOptions();
/*
  Output: {
    min: 0,
    max: 100,
    step: 1,
    value: 0,
    firstValue: 0,
    secondValue: 100,
    isHorizontal: true,
    showBubbles: true,
    showScale: false,
    hasRange: false,
    multiplier: 1,
    values: null,
    customValues: false,
    autofix: false,
    fixConfig: {
      distance: 45,
      count: null,
    }
  }
 */

bindInput

This method can chain any input with a slider.

By default, the slider creates three hidden inputs and chain them with values. So that, chain input will need to invoke method bindInput and give him input and id(property name).

You must chain with right id, because if you use the single slider and chain input with "firstValue" - it's not working.

Example:

<input type="text" name="value">
const slider = $('.my-selector').slider();
const input = document.querySelector('input[name=value]');
slider.bindInput(input, 'value');

or with range slider:

<input type="text" name="min-value">
<input type="text" name="max-value">
const slider = $('.my-selector').slider();
const minInput = document.querySelector('input[name=min-value]');
const maxInput = document.querySelector('input[name=max-value]');

slider.bindInput(minInput, 'firstValue');
slider.bindInput(maxInput, 'secondValue');

Also, you can chain again and old input will be unchaining.

Important! your inputs must be named. Otherwise, will throw an error.

subscribe

This method can subscribe on changes in program. This method receive callback and the name of the action which you can subscribe. Possible names: | Action name | Type of argument to pass | Description | ------------- |:---------------------:| ----------| | optionsUpdate | IOptions | provide new options for callback-subscriber. Invoke each times when options updated. | | valueUpdate | ViewPosition | provide object which have current value and ratio for position. Invoke each times when value updated. | | dragUpdate | RatioData | provide object which have current ratio for position and if slider has range - id handle. Invoke each times when handle been dragged. | | scaleClick | RatioData | provide object which have current ratio for position. Invoke each times when bar has been clicked. | | unitClick | RatioData | provide object which have current ratio for position. Invoke each times when scale unit has been clicked. | | intervalValueUpdate | ViewPosition | provide object which have current ratio for position, value and id handle. Invoke each times when value has been updated. |


3. Building and testing

Clone repository and install dependencies:

git clone [email protected]:sodiqit/FSDSlider.git 
npm i

Run server on localhost:

npm start

Building project:

npm run build

For run test:

npm test

or if you want to check lines coverage

npm run test:coverage