Created
November 18, 2016 07:41
-
-
Save berkin/2904eff5d0941491da2a717e3cdcdf39 to your computer and use it in GitHub Desktop.
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
import scrollParent from './scrolll-parent.js'; | |
if (/Android [4-6]/.test(navigator.appVersion)) { | |
window.addEventListener('resize', () => { | |
if (document.activeElement.tagName === 'INPUT') { | |
window.setTimeout(() => { | |
const el = document.activeElement; | |
const rect = el.getBoundingClientRect(); | |
const container = scrollParent(el); | |
const containerHeight = container.clientHeight; | |
// scroll to center of visible area | |
//console.log(`${rect.top}, ${rect.height}, ${containerHeight}`); | |
container.scrollTop = (rect.top + container.scrollTop + (rect.height / 2)) - (containerHeight / 2); | |
}, 0); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment