Reputation: 763
When editing text fields the native keyboard pops the webview up and leaves it up. just like when you leave the toilet seat up. How do i revert to the original scroll position after the native keyboard have retracted? I there an event that can be caught. I'm thinking of an ugly hack, reloading the entire webview after each edit. It seems like the only way to go.
Upvotes: 0
Views: 1378
Reputation: 3758
Assuming existence of some library that supports CSS selectors:
var positionResetHandler = function () {
var self = {},
lastY = null;
self.inputFieldFocusHandler = function () {
lastY = window.scrollY;
};
self.inputFieldBlurHandler = function () {
if (lastY) {
window.scrollTo(0, lastY);
lastY = null;
}
};
return self;
};
var handler = positionResetHandler();
$("input").bind("focus", handler.inputFieldFocusHandler);
$("input").bind("blur", handler.inputFieldBlurHandler);
On focus of any input field then record the y position of the page. On blur of any input field then scroll the page back to the last known y position
Upvotes: 2