Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Mathias Bynens' iOS viewport scaling bugfix js.

  • Loading branch information...
commit 6a7dc39cf0002bf49b723cb633790d8b3e6706f5 1 parent c2be80d
Dougal Campbell authored
Showing with 30 additions and 0 deletions.
  1. +30 −0 js/ios-scaling-bug-fix.js
30 js/ios-scaling-bug-fix.js
View
@@ -0,0 +1,30 @@
+/**
+ * iOS viewport scaling bug fix
+ * See:
+ * http://filamentgroup.com/examples/iosScaleBug/
+ * https://gist.github.com/901295
+ *
+ * Rewritten version
+ * By @mathias, @cheeaun and @jdalton
+ */
+
+(function(doc) {
+
+ var addEvent = 'addEventListener',
+ type = 'gesturestart',
+ qsa = 'querySelectorAll',
+ scales = [1, 1],
+ meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : [];
+
+ function fix() {
+ meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1];
+ doc.removeEventListener(type, fix, true);
+ }
+
+ if ((meta = meta[meta.length - 1]) && addEvent in doc) {
+ fix();
+ scales = [.25, 1.6];
+ doc[addEvent](type, fix, true);
+ }
+
+}(document));
Please sign in to comment.
Something went wrong with that request. Please try again.