Created
April 3, 2019 18:45
-
-
Save mikbox74/d3aa4775ebd31597ec39479e322bf33e to your computer and use it in GitHub Desktop.
Unputmask + autofill
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(function(){ | |
//autofill event hack | |
$('input.phone').one('animationstart', function(e, f) { | |
var animationName = e.originalEvent.animationName; | |
console.log(animationName); | |
if (animationName == 'onAutoFillCancel') { | |
$(this).inputmask("+7 (999) 999-99-99"); | |
} | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//autofill event hack | |
@keyframes onAutoFillStart { from {/**/} to {/**/}} | |
@keyframes onAutoFillCancel { from {/**/} to {/**/}} | |
input.phone:-webkit-autofill { | |
// Expose a hook for JavaScript when autofill is shown | |
// JavaScript can capture 'animationstart' events | |
animation-name: onAutoFillStart; | |
// Make the background color become yellow really slowly | |
transition: background-color 50000s ease-in-out 0s; | |
} | |
input.phone:not(:-webkit-autofill) { | |
// Expose a hook for JS onAutoFillCancel | |
// JavaScript can capture 'animationstart' events | |
animation-name: onAutoFillCancel; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment