diff options
| author | Stephen Blott | 2014-11-14 08:40:03 +0000 | 
|---|---|---|
| committer | Stephen Blott | 2014-11-14 08:40:03 +0000 | 
| commit | e12b9422580c898af381ba97fa9806bfe3264e96 (patch) | |
| tree | e231ece9a981e5b15f718023617d9550d5370b18 | |
| parent | 59cc099d5be454aabbb46ac3bd0ac30c7ab7c0ff (diff) | |
| download | vimium-e12b9422580c898af381ba97fa9806bfe3264e96.tar.bz2 | |
Smooth scroll; partial fix to race condition.
| -rw-r--r-- | content_scripts/scroller.coffee | 11 | 
1 files changed, 8 insertions, 3 deletions
| diff --git a/content_scripts/scroller.coffee b/content_scripts/scroller.coffee index a1f5bfa1..ecb739ec 100644 --- a/content_scripts/scroller.coffee +++ b/content_scripts/scroller.coffee @@ -89,13 +89,18 @@ doScrollBy = do ->    time = 0    lastEvent = null    keyHandler = null +  keyIsDown = false    (element, direction, amount) ->      return unless amount      keyHandler ?= handlerStack.push -      keydown: -> lastEvent = event -      keyup: -> time += 1 +      keydown: -> +        keyIsDown = true unless event.repeat +        lastEvent = event +      keyup: -> +        keyIsDown = false +        time += 1      unless settings.get "smoothScroll"        # Jump scrolling. @@ -109,7 +114,7 @@ doScrollBy = do ->      activationTime = ++time      isKeyStillDown = -> -      time == activationTime +      time == activationTime and keyIsDown      # Store amount's sign and make amount positive; the logic is clearer when amount is positive.      sign = Math.sign amount | 
