diff options
Diffstat (limited to 'content_scripts/scroller.coffee')
| -rw-r--r-- | content_scripts/scroller.coffee | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/content_scripts/scroller.coffee b/content_scripts/scroller.coffee index 5cc3fd82..27fc9cdc 100644 --- a/content_scripts/scroller.coffee +++ b/content_scripts/scroller.coffee @@ -123,11 +123,15 @@ CoreScroller = @lastEvent = null @keyIsDown = false + # NOTE(smblott) With extreme keyboard configurations, Chrome sometimes does not get a keyup event for + # every keydown, in which case tapping "j" scrolls indefinitely. This appears to be a Chrome/OS/XOrg bug + # of some kind. See #1549. handlerStack.push _name: 'scroller/track-key-status' keydown: (event) => handlerStack.alwaysContinueBubbling => @keyIsDown = true + @time += 1 unless event.repeat @lastEvent = event keyup: => handlerStack.alwaysContinueBubbling => @@ -253,22 +257,22 @@ Scroller = rect = element. getClientRects()?[0] if rect? # Scroll y axis. - if rect.top < 0 - amount = rect.top - 10 + if rect.bottom < 0 + amount = rect.bottom - Math.min(rect.height, window.innerHeight) element = findScrollableElement element, "y", amount, 1 CoreScroller.scroll element, "y", amount, false - else if window.innerHeight < rect.bottom - amount = rect.bottom - window.innerHeight + 10 + else if window.innerHeight < rect.top + amount = rect.top + Math.min(rect.height - window.innerHeight, 0) element = findScrollableElement element, "y", amount, 1 CoreScroller.scroll element, "y", amount, false # Scroll x axis. - if rect.left < 0 - amount = rect.left - 10 + if rect.right < 0 + amount = rect.right - Math.min(rect.width, window.innerWidth) element = findScrollableElement element, "x", amount, 1 CoreScroller.scroll element, "x", amount, false - else if window.innerWidth < rect.right - amount = rect.right - window.innerWidth + 10 + else if window.innerWidth < rect.left + amount = rect.left + Math.min(rect.width - window.innerWidth, 0) element = findScrollableElement element, "x", amount, 1 CoreScroller.scroll element, "x", amount, false |
