From 59e11503f08ee3d37861609eb528c74a4fb8b131 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sun, 21 Dec 2014 20:35:22 -0800 Subject: [PATCH] Stop anomalous scrolling on space/tab in captcha iframe. #231 This is seriously hacky, but probably better than ignoring the issue. Improvements welcome. --- src/Posting/QR.coffee | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 7c3288ff3..66acfd418 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -140,6 +140,19 @@ QR = if $.hasClass(QR.nodes.el, 'autohide') and focus isnt $.hasClass(QR.nodes.el, 'focus') QR.captcha[if focus then 'setup' else 'destroy']() $[if focus then 'addClass' else 'rmClass'] QR.nodes.el, 'focus' + if chrome? + # XXX Stop anomalous scrolling on space/tab in captcha iframe. + if d.activeElement and QR.nodes.el.contains(d.activeElement) and d.activeElement.nodeName is 'IFRAME' + QR.scrollY = window.scrollY + $.on d, 'scroll', QR.scrollLock + $.one d, 'mousemove wheel', -> $.off d, 'scroll', QR.scrollLock + else + $.off d, 'scroll', QR.scrollLock + scrollLock: (e) -> + if d.activeElement and QR.nodes.el.contains(d.activeElement) and d.activeElement.nodeName is 'IFRAME' + window.scroll window.scrollX, QR.scrollY + else + $.off d, 'scroll', QR.scrollLock hide: -> QR.captcha.destroy() d.activeElement.blur()