Created
November 22, 2013 03:33
-
-
Save bguiz/7594363 to your computer and use it in GitHub Desktop.
Workaround for bug in iOS5+ where `position: fixed;` behaves incorrectly when virtual keyboard is opened Solution somewhat similar to: http://stackoverflow.com/a/15537846/194982 Presently simply hides/ shows anything with class 'myFixed' (e.g. a header bar), but may be modified to do fancier things like repositioning it manually with JavaScript…
This file contains 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
function workaroundIosFixedPositionBug() { | |
var isIosSafari = /(iPad|iPhone|iPod)/g.test(navigator.userAgent); | |
if (isIosSafari) { | |
// workaround for bug in iOS5+ where `position: fixed;` behaves incorrectly when virtual keyboard is opened | |
// Solution somewhat similar to: http://stackoverflow.com/a/15537846/194982 | |
// Presently simply hides/ shows anything with class 'myFixed' (e.g. a header bar), but may be modified to do | |
// fancier things like repositioning it manually with javascript, should that be a requirement | |
$('#main').on("focus", "input, textarea", function() { | |
$('.myFixed').css('display', 'none'); | |
}); | |
$('#main').on("blur", "input, textarea", function() { | |
$('.myFixed').css('display', 'block'); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment