Created
June 22, 2010 17:45
-
-
Save sstephenson/448808 to your computer and use it in GitHub Desktop.
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
// Mobile Safari doesn't fire touchstart or touchend events for | |
// input[type=text], input[type=password], input[type=search], | |
// and textarea elements. | |
(function() { | |
if (!("createTouch" in document)) return; | |
var selector = "input[type=text], input[type=password], input[type=search], textarea"; | |
function fire(element, type, identifier) { | |
var touch = document.createTouch(window, element, identifier, 0, 0, 0, 0); | |
var touches = document.createTouchList(touch); | |
var targetTouches = document.createTouchList(touch); | |
var changedTouches = document.createTouchList(touch); | |
var event = document.createEvent("TouchEvent"); | |
event.initTouchEvent(type, true, true, window, null, 0, 0, 0, 0, false, false, false, false, | |
touches, targetTouches, changedTouches, 1, 0); | |
element.dispatchEvent(event); | |
} | |
document.on("mouseup", selector, function(event, element) { | |
var identifier = new Date().getTime(); | |
fire.defer(element, "touchstart", identifier); | |
fire.defer(element, "touchend", identifier); | |
}); | |
})(); |
Just stumbled upon this snippet while searching for documentation on createTouchList()
methods. Do you have an example that would create a TouchList
with more than one touch? Can't seem to find any concrete samples for a multitouch simulated event.
Sorry @KrofDrakula, I'm not quite sure how to do that. You might want to take a look at the (rather sparse) Apple documentation here: http://developer.apple.com/library/safari/#documentation/UserExperience/Reference/DocumentAdditionsReference/DocumentAdditions/DocumentAdditions.html
Yeah, it's missing exactly what I need to complete my proof of concept. Thanks for replying though. Got any more tips on where to look for more info?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sweet!