feat(range): add debounce input for ionChange event

Closes #6894
This commit is contained in:
Manu Mtz.-Almeida
2016-06-16 19:34:46 +02:00
committed by Adam Bradley
parent c15269341f
commit 55eccb3493
4 changed files with 54 additions and 10 deletions

View File

@ -5,6 +5,7 @@ import {Form} from '../../util/form';
import {isTrueProperty, isNumber, isString, isPresent, clamp} from '../../util/util';
import {Item} from '../item/item';
import {pointerCoord, Coordinates, raf} from '../../util/dom';
import {Debouncer} from '../../util/debouncer';
const RANGE_VALUE_ACCESSOR = new Provider(
@ -214,6 +215,7 @@ export class Range {
private _snaps: boolean = false;
private _removes: Function[] = [];
private _mouseRemove: Function;
private _debouncer: Debouncer = new Debouncer(0);
/**
* @private
@ -293,6 +295,17 @@ export class Range {
this._pin = isTrueProperty(val);
}
/**
* @input {number} If true, a pin with integer value is shown when the knob is pressed. Defaults to `false`.
*/
@Input()
get debounce(): number {
return this._debouncer.wait;
}
set debounce(val: number) {
this._debouncer.wait = val;
}
/**
* @input {boolean} Show two knobs. Defaults to `false`.
*/
@ -519,9 +532,10 @@ export class Range {
this.value = newVal;
}
this.onChange(this.value);
this.ionChange.emit(this);
this._debouncer.debounce(() => {
this.onChange(this.value);
this.ionChange.emit(this);
});
}
this.updateBar();