Skip to content

Instantly share code, notes, and snippets.

@publickeating
Created June 28, 2011 04:10
Show Gist options
  • Save publickeating/1050474 to your computer and use it in GitHub Desktop.
Save publickeating/1050474 to your computer and use it in GitHub Desktop.
Pre-running button touch handling to prevent first touch delay
// 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