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 {
|
export class Range implements BaseInputComponent {
|
||||||
// private rangeId: string;
|
|
||||||
// private labelId: string;
|
|
||||||
|
|
||||||
private styleTmr: any;
|
private styleTmr: any;
|
||||||
|
|
||||||
@ -128,7 +126,7 @@ export class Range implements BaseInputComponent {
|
|||||||
|
|
||||||
@PropDidChange('value')
|
@PropDidChange('value')
|
||||||
protected valueChanged(val: boolean) {
|
protected valueChanged(val: boolean) {
|
||||||
this.ionChange.emit({ value: val });
|
setTimeout(() => this.ionChange.emit({value: val}), this.debounce);
|
||||||
this.emitStyle();
|
this.emitStyle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -70,6 +70,9 @@
|
|||||||
<ion-item>
|
<ion-item>
|
||||||
<ion-range dual-knobs="true" id="multiKnob"></ion-range>
|
<ion-range dual-knobs="true" id="multiKnob"></ion-range>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
|
<ion-item>
|
||||||
|
<ion-range id="debounce" debounce="5000"></ion-range>
|
||||||
|
</ion-item>
|
||||||
</ion-list>
|
</ion-list>
|
||||||
|
|
||||||
<ion-button onclick="elTest()">Test</ion-button>
|
<ion-button onclick="elTest()">Test</ion-button>
|
||||||
@ -79,6 +82,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
var knob = document.getElementById('multiKnob')
|
var knob = document.getElementById('multiKnob')
|
||||||
|
var debounceRange = document.getElementById('debounce')
|
||||||
knob.value = {
|
knob.value = {
|
||||||
lower: 33,
|
lower: 33,
|
||||||
upper: 60
|
upper: 60
|
||||||
@ -92,6 +96,9 @@
|
|||||||
knob.addEventListener('ionChange', function(ev) {
|
knob.addEventListener('ionChange', function(ev) {
|
||||||
console.log('change', ev)
|
console.log('change', ev)
|
||||||
})
|
})
|
||||||
|
debounceRange.addEventListener('ionChange', function(ev) {
|
||||||
|
console.log('change', ev)
|
||||||
|
})
|
||||||
|
|
||||||
function elTest() {
|
function elTest() {
|
||||||
var range = document.getElementById('range');
|
var range = document.getElementById('range');
|
||||||
|
|||||||
Reference in New Issue
Block a user