Created
October 14, 2014 19:24
-
-
Save Ricardonacif/880ea9d9238c26e3b8dd to your computer and use it in GitHub Desktop.
Simulate Tap
This file contains hidden or 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
var element_locator = '#fastclick'; | |
function loadYui(callback) { | |
// Adding the script tag to the head as suggested before | |
var head = document.getElementsByTagName('head')[0]; | |
var script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
script.src = "http://yui.yahooapis.com/3.18.0/build/yui/yui-min.js"; | |
// Then bind the event to the callback function. | |
// There are several events for cross browser compatibility. | |
script.onreadystatechange = callback; | |
script.onload = callback; | |
// Fire the loading | |
head.appendChild(script); | |
} | |
var tap = function() { | |
YUI().use('node-event-simulate', function(Y) { | |
var node = Y.one(element_locator); | |
node.simulateGesture("tap"); | |
}); | |
}; | |
if (typeof YUI == 'undefined') { | |
loadYui(tap); | |
} else { | |
tap(); | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment