Skip to content

Instantly share code, notes, and snippets.

@idevwise
Created September 10, 2017 17:15
Show Gist options
  • Save idevwise/8bcb95ddad10c974fd83e36fb3540e43 to your computer and use it in GitHub Desktop.
Save idevwise/8bcb95ddad10c974fd83e36fb3540e43 to your computer and use it in GitHub Desktop.
JavaScript for the absolutely positioned layout built for
document.addEventListener('DOMContentLoaded', () => {
setPlatformInfo();
var inputBox = document.querySelector('.safari #inputBox');
if(inputBox) {
inputBox.addEventListener('focus', function(e) {
document.body.classList.add('keyboard');
setTimeout(function() {
window.scrollTo(0, 0);
}, 200);
});
inputBox.addEventListener('blur', function(e) {
document.body.classList.remove('keyboard');
});
}
});
function setPlatformInfo() {
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf('safari') != -1) {
if (ua.indexOf('chrome') > -1) {
document.body.classList.add('chrome');
} else {
document.body.classList.add('safari');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment