Code Monkey home page Code Monkey logo

npnslider's Introduction

NpnSlider (A Multi Range Slider Component)

Build Status

NpnSlider is a reusable range slider component using Angular v6.0. It can be used either as a multi range or a single range slider. By default, it is a multi range slider.

Installation

npm install --save npn-slider
yarn add npn-slider

Usage

Html

<npn-slider [min]="2006" [max]="2020" (onChange)="onSliderChange($event)"></npn-slider>

Attributes

Attributes Description
@Input()
min: number
The minimum value of slider
@Input()
max: number
The maximum value of slider
@Input()
step: number
The value at which slider value should change
@Input()
showStepIndicator: boolean
Whether the step indicator should display or not
@Input()
minSelected: number
The selected value for slider's left handler
@Input()
maxSelected: number
The selected value for slider's right handler
@Input()
disabled: string
To disable the slider. Valid values: 'true' or 'disabled' or empty attribute
@Input()
multiRange: boolean
To switch between Mutli range and Single range mode. Slider is multi range by default
@Input()
hide-tooltip: boolean
To hide the tooltip that shows on hover of slider handler. Default value: 'false'
@Input()
hide-values: boolean
To hide values displayed at bottom of slider. Default value: 'false'
@Output()
onChange: EventEmitter<number[]>()
The event will be fired on change of selected range of values.
Returns: Selected range of values as an array[],
On Single range mode, a number array with single value will be returned

Example and Sample Code

a) Import 'NpnSliderModule' in your app module

import { NpnSliderModule } from "npn-slider";
  
@NgModule({
  imports:[
    ..
    NpnSliderModule
    ..
  ]
})

b) Add 'npn-slider' in your component html

<npn-slider [min]="1000" [max]="5000" (onChange)="onSliderChange($event)" [step]="500" [showStepIndicator]="true"></npn-slider>

c) Add a method in your component class to listen for onChange event from slider

/*Method to listen for onChange event from slider*/
onSliderChange(selectedValues: number[]) {
    this._currentValues = selectedValues;
}

d) You done. Run your app. cheers!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.