Adding Scott Jehl's fix for the iOS orientation bug
[ReadingsJQM.git] / js / ios-orientationchange-fix.min.js
diff --git a/js/ios-orientationchange-fix.min.js b/js/ios-orientationchange-fix.min.js
new file mode 100644 (file)
index 0000000..83ff5b1
--- /dev/null
@@ -0,0 +1,5 @@
+/*
+       A fix for the iOS orientationchange zoom bug. Script by @scottjehl, rebound by @wilto.MIT License.
+       https://github.com/scottjehl/iOS-Orientationchange-Fix
+*/
+(function(m){if(!(/iPhone|iPad|iPod/.test(navigator.platform)&&navigator.userAgent.indexOf("AppleWebKit")>-1)){return}var l=m.document;if(!l.querySelector){return}var n=l.querySelector("meta[name=viewport]"),a=n&&n.getAttribute("content"),k=a+",maximum-scale=1",d=a+",maximum-scale=10",g=true,j,i,h,c;if(!n){return}function f(){n.setAttribute("content",d);g=true}function b(){n.setAttribute("content",k);g=false}function e(o){c=o.accelerationIncludingGravity;j=Math.abs(c.x);i=Math.abs(c.y);h=Math.abs(c.z);if(!m.orientation&&(j>7||((h>6&&i<8||h<8&&i>6)&&j>5))){if(g){b()}}else{if(!g){f()}}}m.addEventListener("orientationchange",f,false);m.addEventListener("devicemotion",e,false)})(this);
\ No newline at end of file