Giter VIP home page Giter VIP logo

ngx-slider-moby's Introduction

Ngx Slider Moby.

Reactive slider/scope slider component for angular.

Live demo: https://pavelpleshko-slider-moby.now.sh

Screenshot

main_screen

Get started

Slider supports touch events for mobile devices.

Install package itself

npm install ngx-slider-moby --save

How to use

Include NgxSliderMobyModule into your module like so:

import { NgxSliderMobyModule } from 'ngx-slider-moby';
...
@NgModule({
  imports: [
    NgxSliderMobyModule
  ],
})
export class YourModule { }

Inclusion of module will give you access to the slider component which you can include in your components. Example:

<ngx-slider-moby [max_value]="300" [min_value]="0" [range]="true"></ngx-slider-moby>

Can be used as form control(implements ControlValueAccessor interface) like so:

<div [formGroup]="myForm">
<ngx-slider-moby [max_value]="300" [min_value]="0" [range]="true" formControlName="priceRange"></ngx-slider-moby>
<ngx-slider-moby [max_value]="10" [min_value]="0" [range]="false" formControlName="kilogramms"></ngx-slider-moby>
</div>

NOTE: In case when you are using [range]="true" form control value will be as follows:

{from:20,to:55}

NOTE: If you want to use vertical slider specifying [vertical]="true" parent's height should be also specified otherwise component will behave unexpectedly.

Inputs

Prop Type Default Description
min_value number 0 minimal value for given slider
max_value number 500 maximal value for given slider
value_from number 0 If specified will assign provided value to the component value1 variable
value_to number 0 Similar with above but for value2 variable
showThumbLabels boolean true whether or not to show labels on default slider(not range)
vertical boolean true If false then the slider will appear horizontally
step number 1 Allows to specify the number of units that one step has
range boolean false If speified true then the slider will be a scope slider and have corresponding value and appearance(ex.: from 30 to 50). Thumblabels are visible by default in this type of slider
disabled boolean false If true then puts slider in a disabled state and doesn't handle any events on the element
direction 'ltr' or 'rtl' ltr Left to right or right to left(not implemeneted yet)
color string purple Slider will assume the corresponding color palette. Options: red,green,blue,purple,yellow

Events

valueChange - emits the object which looks like this in case of default slider {sliderId:string,value:number,percent:number},in case of range slider as follows:

{sliderId:string, value: {from:number,to:number}, percent: {from:number,to:number} }

blurred - blur event emits boolean true or false;

focused - focus event emits boolean true or false;

Update 2.0.0 info.

  1. Major bug fixes.
  2. Animation runs smoother.

Update 1.1.0 info.

  1. Added colors 'black','grey'.
  2. Added support of floating step.
  3. Fixed some bugs.

ngx-slider-moby's People

Contributors

angular-cli avatar pavelpleshko avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

lsrael-bgx

ngx-slider-moby's Issues

Default Value when range is false

How to set default value when range is false?
Which of these two properties should I change?

this.currentRange = { from: null, to: null };
this.defaultCurrentRange = { from: 50, to: 70 };

My config component:
<ngx-slider-moby
[max_value]="4500"
[min_value]="0"
[color]="'blue'"
[showThumbLabels]="true"
[step]="500"
[value_from]="1000"
[range]="false"
(valueChange)="valueChanged($event)"
[(ngModel)]="value">

UPDATE:
When max_value is greater to 500 the property value_from in slider showing wrong. It is return value 500 as max_value

Object.defineProperty(NgxSliderMobyComponent.prototype, "max_value", {
get: function () {
console.log(this._max_value);
return this._max_value || 500;
},
set: function (val) {
this._max_value = Number(val);
},
enumerable: true,
configurable: true
});

ExpressionChangedAfterItHasBeenCheckedError:

I did exactly what you provide but unfortunately I'm getting error
ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'ng-pristine: true'. Current value: 'ng-pristine: false'.
at viewDebugError (core.js:7601)
at expressionChangedAfterItHasBeenCheckedError (core.js:7589)
at checkBindingNoChanges (core.js:7691)
at checkNoChangesNodeInline (core.js:10556)
at checkNoChangesNode (core.js:10541)
at debugCheckNoChangesNode (core.js:11144)
at debugCheckRenderNodeFn (core.js:11098)
at Object.eval [as updateRenderer] (AppComponent.html:20)
at Object.debugUpdateRenderer [as updateRenderer] (core.js:11087)
at checkNoChangesView (core.js:10442)
View_AppComponent_0 @ AppComponent.html:20
proxyClass @ compiler.js:10168
push../node_modules/@angular/core/fesm5/core.js.DebugContext_.logError @ core.js:11313
push../node_modules/@angular/core/fesm5/core.js.ErrorHandler.handleError @ core.js:1719
(anonymous) @ core.js:4588
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke @ zone.js:388
push../node_modules/zone.js/dist/zone.js.Zone.run @ zone.js:138
push../node_modules/@angular/core/fesm5/core.js.NgZone.runOutsideAngular @ core.js:3783
push../node_modules/@angular/core/fesm5/core.js.ApplicationRef.tick @ core.js:4588
push../node_modules/@angular/core/fesm5/core.js.ApplicationRef.loadComponent @ core.js:4615
push../node_modules/@angular/core/fesm5/core.js.ApplicationRef.bootstrap @ core.js:4557
(anonymous) @ core.js:4358
push../node_modules/@angular/core/fesm5/core.js.PlatformRef.moduleDoBootstrap @ core.js:4358
(anonymous) @ core.js:4324
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke @ zone.js:388
onInvoke @ core.js:3824
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke @ zone.js:387
push../node_modules/zone.js/dist/zone.js.Zone.run @ zone.js:138
(anonymous) @ zone.js:872
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask @ zone.js:421
onInvokeTask @ core.js:3815
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask @ zone.js:420
push../node_modules/zone.js/dist/zone.js.Zone.runTask @ zone.js:188
drainMicroTaskQueue @ zone.js:595
Promise.then (async)
scheduleMicroTask @ zone.js:578
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.scheduleTask @ zone.js:410
push../node_modules/zone.js/dist/zone.js.Zone.scheduleTask @ zone.js:232
push../node_modules/zone.js/dist/zone.js.Zone.scheduleMicroTask @ zone.js:252
scheduleResolveOrReject @ zone.js:862
ZoneAwarePromise.then @ zone.js:962
push../node_modules/@angular/core/fesm5/core.js.PlatformRef.bootstrapModule @ core.js:4353
./src/main.ts @ main.ts:11
webpack_require @ bootstrap:76
0 @ main.ts:12
webpack_require @ bootstrap:76
checkDeferredModules @ bootstrap:43
webpackJsonpCallback @ bootstrap:30
(anonymous) @ main.js:1
AppComponent.html:20 ERROR CONTEXT DebugContext
 {view: {…}, nodeIndex: 19, nodeDef: {…}, elDef: {…}, elView: {…}}
View_AppComponent_0 @ AppComponent.html:20
proxyClass @ compiler.js:10168
push../node_modules/@angular/core/fesm5/core.js.DebugContext
.logError @ core.js:11313
push../node_modules/@angular/core/fesm5/core.js.ErrorHandler.handleError @ core.js:1724
(anonymous) @ core.js:4588
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke @ zone.js:388
push../node_modules/zone.js/dist/zone.js.Zone.run @ zone.js:138
push../node_modules/@angular/core/fesm5/core.js.NgZone.runOutsideAngular @ core.js:3783
push../node_modules/@angular/core/fesm5/core.js.ApplicationRef.tick @ core.js:4588
push../node_modules/@angular/core/fesm5/core.js.ApplicationRef._loadComponent @ core.js:4615
push../node_modules/@angular/core/fesm5/core.js.ApplicationRef.bootstrap @ core.js:4557
(anonymous) @ core.js:4358
push../node_modules/@angular/core/fesm5/core.js.PlatformRef._moduleDoBootstrap @ core.js:4358
(anonymous) @ core.js:4324
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke @ zone.js:388
onInvoke @ core.js:3824
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke @ zone.js:387
push../node_modules/zone.js/dist/zone.js.Zone.run @ zone.js:138
(anonymous) @ zone.js:872
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask @ zone.js:421
onInvokeTask @ core.js:3815
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask @ zone.js:420
push../node_modules/zone.js/dist/zone.js.Zone.runTask @ zone.js:188
drainMicroTaskQueue @ zone.js:595
Promise.then (async)
scheduleMicroTask @ zone.js:578
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.scheduleTask @ zone.js:410
push../node_modules/zone.js/dist/zone.js.Zone.scheduleTask @ zone.js:232
push../node_modules/zone.js/dist/zone.js.Zone.scheduleMicroTask @ zone.js:252
scheduleResolveOrReject @ zone.js:862
ZoneAwarePromise.then @ zone.js:962
push../node_modules/@angular/core/fesm5/core.js.PlatformRef.bootstrapModule @ core.js:4353
./src/main.ts @ main.ts:11
webpack_require @ bootstrap:76
0 @ main.ts:12
webpack_require @ bootstrap:76
checkDeferredModules @ bootstrap:43
webpackJsonpCallback @ bootstrap:30
(anonymous) @ main.js:1
core.js:3123 Angular is running in the development mode. Call enableProdMode() to enable the production mode

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.