maz-ui
Version:
A standalone components library for Vue.Js 3 & Nuxt.Js 3
8 lines • 928 B
JavaScript
var ANIMATION_NAME=`maz-autofill-start`;var STYLE_ELEMENT_ID=`maz-autofill-sync`;function ensureStylesInjected(){if(typeof document>`u`||document.getElementById(STYLE_ELEMENT_ID))return;let style=document.createElement(`style`);style.id=STYLE_ELEMENT_ID,style.textContent=`
@keyframes ${ANIMATION_NAME} { from {} to {} }
[data-maz-autofill-sync]:-webkit-autofill,
[data-maz-autofill-sync]:autofill {
animation-name: ${ANIMATION_NAME};
animation-duration: 1ms;
}
`,document.head.appendChild(style)}function onAutofillSync(field,onSync){ensureStylesInjected(),field.setAttribute(`data-maz-autofill-sync`,``);function handleAnimationStart(event){event.animationName===ANIMATION_NAME&&onSync(event.target.value)}return field.addEventListener(`animationstart`,handleAnimationStart),()=>{field.removeEventListener(`animationstart`,handleAnimationStart),field.removeAttribute(`data-maz-autofill-sync`)}}export{onAutofillSync as t};