feat(inputs): adds deferEvent helper

This commit is contained in:
Manu Mtz.-Almeida
2018-02-21 16:00:19 +01:00
parent beee484735
commit 9e4bae74ab
3 changed files with 8 additions and 4 deletions

View File

@ -1,6 +1,6 @@
import { BlurEvent, CheckboxInput, CheckedInputChangeEvent, FocusEvent, StyleEvent } from '../../utils/input-interfaces';
import { Component, CssClassMap, Event, EventEmitter, Prop, State, Watch } from '@stencil/core';
import { debounceEvent } from '../../utils/helpers';
import { deferEvent } from '../../utils/helpers';
@Component({
@ -81,7 +81,7 @@ export class Checkbox implements CheckboxInput {
}
componentDidLoad() {
this.ionStyle = debounceEvent(this.ionStyle, 0);
this.ionStyle = deferEvent(this.ionStyle);
this.didLoad = true;
const parentItem = this.nativeInput.closest('ion-item');

View File

@ -2,7 +2,7 @@ import { BlurEvent, CheckboxInput, CheckedInputChangeEvent, FocusEvent, StyleEve
import { Component, Event, EventEmitter, Prop, State, Watch } from '@stencil/core';
import { GestureDetail } from '../../index';
import { hapticSelection } from '../../utils/haptic';
import { debounceEvent } from '../../utils/helpers';
import { deferEvent } from '../../utils/helpers';
@Component({
@ -98,7 +98,7 @@ export class Toggle implements CheckboxInput {
}
componentWillLoad() {
this.ionStyle = debounceEvent(this.ionStyle, 0);
this.ionStyle = deferEvent(this.ionStyle);
this.inputId = `ion-tg-${toggleIds++}`;
if (this.name === undefined) {
this.name = this.inputId;

View File

@ -286,6 +286,10 @@ export function domControllerAsync(domControllerFunction: Function, callback?: F
});
}
export function deferEvent(event: EventEmitter): EventEmitter {
return debounceEvent(event, 0);
}
export function debounceEvent(event: EventEmitter, wait: number): EventEmitter {
const original = (event as any)._original || event;
return {