Created
December 22, 2010 02:41
-
-
Save doctyper/751002 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
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
// The reason I had to do this? The Google Maps v3 API prevents default touchmove event behavior on the body element. | |
// For this, it uses an anonymous function and does not offer an API to disable this. | |
// So... I forced it to. | |
// Added by Richard Herrera on 12/21/10 | |
// WAY HACKY. Easily the most hacky thing I've ever done. Cool as hell though. | |
// Store reference to original method. We'll need this later | |
Event.prototype._preventDefault = Event.prototype.preventDefault; | |
// Overtake preventDefault!! | |
Event.prototype.preventDefault = function () { | |
// So what we want to do is stop the preventDefault method from firing if: | |
// - Event type is touchmove AND | |
// - A .pane or #post-overlay is active. | |
// If both are false, the original _preventDefault method is applied | |
// Otherwise, _preventDefault does not get applied. Victory! | |
if (!$(".pane.active, #post-overlay[class]").get(0) && this.type !== "touchmove") { | |
// Apply the preventDefault method as normal | |
Event.prototype._preventDefault.apply(this, [].slice.call(arguments)); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment