Created
June 28, 2011 04:10
-
-
Save publickeating/1050474 to your computer and use it in GitHub Desktop.
Pre-running button touch handling to prevent first touch delay
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
// at the end of main.js... | |
var buttonView = SC.ButtonView.create({ | |
layout: { left: -1000, width: 100, height: 24, top: 0 }, | |
didAppendToDocument: function() { | |
var self = this, | |
layer = this.get('layer'), | |
params; | |
params = { | |
target: layer, | |
pageX: -980, | |
pageY: 10, | |
screenX: -980, | |
screenY: 10, | |
clientX: -980, | |
clientY: 10, | |
preventDefault: function() {} | |
}; | |
// simulate touchstart | |
this.invokeLater(function() { | |
SC.platform._simtouch_mousedown(params); | |
// remove ourself | |
self.invokeLast(function() { | |
self.removeFromParent.call(self); | |
}); | |
}); | |
return this; | |
} | |
}); | |
Sproutgap.getPath('mainPage.mainPane').appendChild(buttonView); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment