You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.0 KiB
35 lines
1.0 KiB
import coreModule from './core_module';
|
|
|
|
/** @ngInject */
|
|
export function autofillEventFix($compile: any) {
|
|
return {
|
|
link: ($scope: any, elem: any) => {
|
|
const input = elem[0];
|
|
const dispatchChangeEvent = () => {
|
|
const event = new Event('change');
|
|
return input.dispatchEvent(event);
|
|
};
|
|
const onAnimationStart = ({ animationName }: AnimationEvent) => {
|
|
switch (animationName) {
|
|
case 'onAutoFillStart':
|
|
return dispatchChangeEvent();
|
|
case 'onAutoFillCancel':
|
|
return dispatchChangeEvent();
|
|
}
|
|
return null;
|
|
};
|
|
|
|
// const onChange = (evt: Event) => console.log(evt);
|
|
|
|
input.addEventListener('animationstart', onAnimationStart);
|
|
// input.addEventListener('change', onChange);
|
|
|
|
$scope.$on('$destroy', () => {
|
|
input.removeEventListener('animationstart', onAnimationStart);
|
|
// input.removeEventListener('change', onChange);
|
|
});
|
|
},
|
|
};
|
|
}
|
|
|
|
coreModule.directive('autofillEventFix', autofillEventFix);
|
|
|