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

input-range

v1.2.9

Published

[![NPM version][npm-image]][npm-url] [![npm download][download-image]][download-url] [![npm license][license-image]][download-url]

Downloads

54

Readme

Input range 🎉

NPM version npm download npm license

中文文档

InputRange is a slide bar plugin, he simulates native input range component and makes you can highly customize the dom structure and the css style, if you don't want write dom structure and css style by yourself, InputRange provided react component and vue component. Detailed usage can be seen here

Effect

effect

Installation

  npm install input-range --save

or

  yarn add input-range

About react and vue component

How to use

InputRange has two ways to initialize

  const { Slide, createSlide } from 'input-range'

  // The first
  const slide = new Slide(options)
  slide.init()

  // The second
  const slide = createSlide(options)
  slide.init()

you can initialize appropriately after slide instance be created, for example, a dom element initially hidden and later displayed

options description

options except point,are all optional

| Name | Description | Type | Default | |------------|-------------|------|---------| | point | slider button | element || string | undefined | | direction | slider active direction | 'x' || 'y' | 'x' | | limit_area | limit range while draging | number | 100 | | pointer_event | whether to add the pointer-events attribute to the style of the slider | boolean | true | | prohibit_click | whether to prohibit clicking slider | boolean | false | | prohibit_move | whether to prohibit draging slider | boolean | false | | click_el_index | Specifing which element of container triggers the click event (index starts from 0) | number | 0 | | expand_touch_area | expand touch range | Object | undefined |

expand_touch_area description

| Name | Description | Type | |------------|-------------|------| | width | width | number || string | | height | height | number || string |

Instance attributes

value

siide.value record current slider value, value range is 0 to 1. It should be noted that the slide will be set to the default value according to the css value of the slide progress during initialization. slide doesn't provide default value interface, so you can achieve default value by html structure or dispatch method.

  <div class="container">
    <span class="background"></span>
    <span class="progress">
      <i class="dot"></i>
    </span>
  </div>

  <style>
    .progress {
      width: 30%;
    }
  </style>

  <script>
    // If direction is 'x'
    const slide = new Slide(options)
    slide.init()
    slide.value // 0.3
  </script>

or

  const slide = new Slide(options)
  slide.init()
  slide.dispatch('change', 0.1)

api

Hook functions

init

You can use init method to reset parameters in anytime.

  const slide = new Slide(options)
  slide.init()

dispatch

You can trigger the event manually, yeah! dispatch.

  // event type must be input or change
  // value must be between 0 and 1
  // you can use transition animate
  slide.dispatch('input', 1, true)

prohibit_click

This method use to prohibit clicking slide bar or cancel.

  slide.prohibit_click(true)
  // or
  slide.prohibit_click(false)

prohibit_move

This method use to prohibit draging slide bar or cancel.

  slide.prohibit_move(true)
  // or
  slide.prohibit_move(false)

oninput

You can compare this method to the callback of the input event of the native input range component.

  slide.oninput = function(value, progress_el, slide) {
    ...
  }

You also can achieve similiar effect by rigistering input event on html element.

  <span class="progress" id="p"></span>

  <script>
    p.addEventListener('input', e => {
      const value = e.value
      ...
    })
  </script>

onchange

The onchange hook function is similiar with oninput, which is also simulating the native change event, except that you need to change input to change.

onerror

The onerror hook function accept error which InputRange send.

  slide.onerror = function (err_msg, stacks) {
    ...
  }