Created
April 4, 2011 08:30
-
Star
(169)
You must be signed in to star a gist -
Fork
(28)
You must be signed in to fork a gist
-
-
Save mathiasbynens/901295 to your computer and use it in GitHub Desktop.
Revisions
-
mathiasbynens revised this gist
Apr 12, 2011 . 1 changed file with 15 additions and 11 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,19 +1,23 @@ // 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)); -
mathiasbynens revised this gist
Apr 4, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -14,6 +14,6 @@ fixMetas(true); doc.addEventListener('gesturestart', fixMetas, false); }(document)); -
mathiasbynens revised this gist
Apr 4, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ forEach = [].forEach; function fixMetas(isFirstTime) { var scales = isFirstTime === true ? ['1.0', '1.0'] : ['0.25', '1.6']; forEach.call(metas, function(el) { el.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1]; }); -
mathiasbynens revised this gist
Apr 4, 2011 . 2 changed files with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.File renamed without changes. -
mathiasbynens revised this gist
Apr 4, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ // Original code from http://www.blog.highub.com/mobile-2/a-fix-for-iphone-viewport-scale-bug/ var metas = document.getElementsByTagName('meta'); var i; -
mathiasbynens revised this gist
Apr 4, 2011 . 1 changed file with 7 additions and 8 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,20 +1,19 @@ // My rewritten version (function(doc) { var metas = doc.querySelectorAll('meta[name="viewport"]'), forEach = [].forEach; function fixMetas(isFirstTime) { var scales = isFirstTime ? ['1.0', '1.0'] : ['0.25', '1.6']; forEach.call(metas, function(el) { el.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1]; }); } fixMetas(true); doc.body.addEventListener('gesturestart', fixMetas, false); }(document)); -
mathiasbynens revised this gist
Apr 4, 2011 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ // My rewritten version (function() { var metas = document.querySelectorAll('meta[name="viewport"]'), -
mathiasbynens revised this gist
Apr 4, 2011 . 2 changed files with 20 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ // Original code form http://www.blog.highub.com/mobile-2/a-fix-for-iphone-viewport-scale-bug/ var metas = document.getElementsByTagName('meta'); var i; if (navigator.userAgent.match(/iPhone/i)) { for (i=0; i<metas.length; i++) { if (metas[i].name == "viewport") { metas[i].content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0"; } } document.getElementsByTagName('body')[0].addEventListener("gesturestart", gestureStart, false); } function gestureStart() { for (i=0; i<metas.length; i++) { if (metas[i].name == "viewport") { metas[i].content = "width=device-width, minimum-scale=0.25, maximum-scale=1.6"; } } } 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ // My rewritten version (function() { var metas = document.querySelectorAll('meta[name="viewport"]'), -
mathiasbynens renamed this gist
Apr 4, 2011 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
mathiasbynens created this gist
Apr 4, 2011 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ (function() { var metas = document.querySelectorAll('meta[name="viewport"]'), forEach = [].forEach; function fixMetas(firstTime) { forEach.call(metas, function(el) { el.content = firstTime ? 'width=device-width,minimum-scale=1.0,maximum-scale=1.0' : 'width=device-width,minimum-scale=0.25,maximum-scale=1.6'; }); } fixMetas(true); document.body.addEventListener('gesturestart', fixMetas, false); }());