From eaab5c64f04920fa8915cf71ab508ad569f5c029 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 25 Mar 2015 16:37:30 +1100 Subject: [PATCH] window scroll event wreaks havoc, get rid of it. --- app/assets/javascripts/discourse/lib/safari-hacks.js.es6 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/discourse/lib/safari-hacks.js.es6 b/app/assets/javascripts/discourse/lib/safari-hacks.js.es6 index abbb9a5ebf1..a73d8802077 100644 --- a/app/assets/javascripts/discourse/lib/safari-hacks.js.es6 +++ b/app/assets/javascripts/discourse/lib/safari-hacks.js.es6 @@ -30,7 +30,6 @@ function positioningWorkaround($fixedElement) { if (evt) { evt.target.removeEventListener('blur', blurred); } - $(window).off('scroll.position-hack'); }; var blurred = _.debounce(blurredNow, 250); @@ -63,7 +62,7 @@ function positioningWorkaround($fixedElement) { var oldScrollY = 0; - var positionElement = _.debounce(function(){ + var positionElement = function(){ if (done) { return; } @@ -72,9 +71,10 @@ function positioningWorkaround($fixedElement) { } oldScrollY = window.scrollY; 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(); self.focus(); @@ -91,6 +91,7 @@ function positioningWorkaround($fixedElement) { $fixedElement.find('button,a').each(function(){ attachTouchStart(this, function(evt){ done = true; + $(document.activeElement).blur(); evt.preventDefault(); $(this).click(); });