window scroll event wreaks havoc, get rid of it.

This commit is contained in:
Sam 2015-03-25 16:37:30 +11:00
parent 692433f0cf
commit eaab5c64f0

View File

@ -30,7 +30,6 @@ function positioningWorkaround($fixedElement) {
if (evt) { if (evt) {
evt.target.removeEventListener('blur', blurred); evt.target.removeEventListener('blur', blurred);
} }
$(window).off('scroll.position-hack');
}; };
var blurred = _.debounce(blurredNow, 250); var blurred = _.debounce(blurredNow, 250);
@ -63,7 +62,7 @@ function positioningWorkaround($fixedElement) {
var oldScrollY = 0; var oldScrollY = 0;
var positionElement = _.debounce(function(){ var positionElement = function(){
if (done) { if (done) {
return; return;
} }
@ -72,9 +71,10 @@ function positioningWorkaround($fixedElement) {
} }
oldScrollY = window.scrollY; oldScrollY = window.scrollY;
fixedElement.style.top = window.scrollY + iPadOffset + 'px'; fixedElement.style.top = window.scrollY + iPadOffset + 'px';
}, 400); };
$(window).on('scroll.position-hack', positionElement); // position once, correctly, after keyboard is shown
setTimeout(positionElement, 500);
evt.preventDefault(); evt.preventDefault();
self.focus(); self.focus();
@ -91,6 +91,7 @@ function positioningWorkaround($fixedElement) {
$fixedElement.find('button,a').each(function(){ $fixedElement.find('button,a').each(function(){
attachTouchStart(this, function(evt){ attachTouchStart(this, function(evt){
done = true; done = true;
$(document.activeElement).blur();
evt.preventDefault(); evt.preventDefault();
$(this).click(); $(this).click();
}); });