mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-09 16:16:41 +08:00
feat(range): add debounce support
This commit is contained in:
@ -13,8 +13,6 @@ import { clamp } from '../../utils/helpers';
|
||||
}
|
||||
})
|
||||
export class Range implements BaseInputComponent {
|
||||
// private rangeId: string;
|
||||
// private labelId: string;
|
||||
|
||||
private styleTmr: any;
|
||||
|
||||
@ -128,7 +126,7 @@ export class Range implements BaseInputComponent {
|
||||
|
||||
@PropDidChange('value')
|
||||
protected valueChanged(val: boolean) {
|
||||
this.ionChange.emit({ value: val });
|
||||
setTimeout(() => this.ionChange.emit({value: val}), this.debounce);
|
||||
this.emitStyle();
|
||||
}
|
||||
|
||||
|
||||
@ -70,6 +70,9 @@
|
||||
<ion-item>
|
||||
<ion-range dual-knobs="true" id="multiKnob"></ion-range>
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
<ion-range id="debounce" debounce="5000"></ion-range>
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
|
||||
<ion-button onclick="elTest()">Test</ion-button>
|
||||
@ -79,6 +82,7 @@
|
||||
|
||||
<script>
|
||||
var knob = document.getElementById('multiKnob')
|
||||
var debounceRange = document.getElementById('debounce')
|
||||
knob.value = {
|
||||
lower: 33,
|
||||
upper: 60
|
||||
@ -92,6 +96,9 @@
|
||||
knob.addEventListener('ionChange', function(ev) {
|
||||
console.log('change', ev)
|
||||
})
|
||||
debounceRange.addEventListener('ionChange', function(ev) {
|
||||
console.log('change', ev)
|
||||
})
|
||||
|
||||
function elTest() {
|
||||
var range = document.getElementById('range');
|
||||
|
||||
Reference in New Issue
Block a user