mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-24 23:01:57 +08:00
feat(inputs): adds deferEvent helper
This commit is contained in:
@ -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');
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
Reference in New Issue
Block a user