Last active
October 29, 2016 18:14
-
-
Save taivo/ec78e20e9e3efb15fab4 to your computer and use it in GitHub Desktop.
Remove 300ms delay from google maps autocomplete in ionic framework. Inspired by http://davidwalsh.name/detect-node-insertion . Tested on: Nexus 5 Android, Nexus 7 tablet, and iPhone 6 Safari
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
// | |
// CSS - define a keyframe animation called 'nodeInserted' | |
// | |
@keyframes nodeInserted { | |
from { opacity: 0.99; } | |
to { opacity: 1; } | |
} | |
@-webkit-keyframes nodeInserted{ | |
from { opacity: 0.99; } | |
to { opacity: 1; } | |
} | |
div.pac-container { | |
animation-duration: 0.001s; | |
animation-name: nodeInserted; | |
-webkit-animation-duration: 0.001s; | |
-webkit-animation-name: nodeInserted; | |
} | |
// | |
// Jquery - listen for 'nodeInserted' | |
// note the 'one' event registration to avoid repeating the same task | |
// | |
$(document).one('animationstart webkitAnimationStart MSAnimationStart', 'div.pac-container', function(event){ | |
if(event.originalEvent.animationName === 'nodeInserted'){ | |
$(event.target).attr('data-tap-disabled', true).click(function(){ | |
$('#myAutocompleteInputElem').blur(); //closes the selection drop down | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do you have a solution for ionic V2 ? thanks !