diff options
| author | Stephen Blott | 2015-01-22 11:39:21 +0000 | 
|---|---|---|
| committer | Stephen Blott | 2015-01-22 14:15:43 +0000 | 
| commit | d7b416747e5cf6971737a3f70243618419a1ac4b (patch) | |
| tree | 2e7aae49e1f345768ceb27eb2afe9ba677992f37 /content_scripts/scroller.coffee | |
| parent | dd9b2e9550a48c8e6e7a4a56b530ac8060279b12 (diff) | |
| download | vimium-d7b416747e5cf6971737a3f70243618419a1ac4b.tar.bz2 | |
Visual/edit modes: further development.
- Better abstraction.
- Add HUD message on yank.
- Require initial selection for visual mode.
- Try to start with a visible selection.
- Scroll the active end of the selection into view (with smooth
  scrolling, if enabled).
Diffstat (limited to 'content_scripts/scroller.coffee')
| -rw-r--r-- | content_scripts/scroller.coffee | 14 | 
1 files changed, 13 insertions, 1 deletions
| diff --git a/content_scripts/scroller.coffee b/content_scripts/scroller.coffee index 6e2e1ffc..f31c4a6b 100644 --- a/content_scripts/scroller.coffee +++ b/content_scripts/scroller.coffee @@ -146,7 +146,7 @@ CoreScroller =    calibrationBoundary: 150 # Boundary between scrolls which are considered too slow, or too fast.    # Scroll element by a relative amount (a number) in some direction. -  scroll: (element, direction, amount) -> +  scroll: (element, direction, amount, continuous = true) ->      return unless amount      unless @settings.get "smoothScroll" @@ -202,6 +202,10 @@ CoreScroller =          # We're done.          checkVisibility element +    # If we've been asked not to be continuous, then we advance time, so the myKeyIsStillDown test always +    # fails. +    ++@time unless continuous +      # Launch animator.      requestAnimationFrame animate @@ -242,5 +246,13 @@ Scroller =      amount = getDimension(element,direction,pos) - element[scrollProperties[direction].axisName]      CoreScroller.scroll element, direction, amount +  scrollIntoView: (element) -> +    activatedElement ||= document.body and firstScrollableElement() +    rect = element.getBoundingClientRect() +    if rect.top < 0 +      CoreScroller.scroll activatedElement, "y", rect.top - 50, false +    else if window.innerHeight < rect.bottom +      CoreScroller.scroll activatedElement, "y", 50 + rect.bottom - window.innerHeight, false +  root = exports ? window  root.Scroller = Scroller | 
