diff options
| author | Stephen Blott | 2016-03-16 12:09:25 +0000 | 
|---|---|---|
| committer | Stephen Blott | 2016-03-28 05:58:42 +0100 | 
| commit | f49d4b2f5980d48e76fd2e32491c9793f5f6fdf8 (patch) | |
| tree | 12538bf3064deb3180034f2ac938d28c87af5b0e /content_scripts/scroller.coffee | |
| parent | 2a62e4811fc2360257dd99066b4caa3e95025cbf (diff) | |
| download | vimium-f49d4b2f5980d48e76fd2e32491c9793f5f6fdf8.tar.bz2 | |
Make scrollable elements selectable with hints.
Fixes #425.
Conflicts:
	content_scripts/scroller.coffee
Diffstat (limited to 'content_scripts/scroller.coffee')
| -rw-r--r-- | content_scripts/scroller.coffee | 13 | 
1 files changed, 9 insertions, 4 deletions
| diff --git a/content_scripts/scroller.coffee b/content_scripts/scroller.coffee index f83d0e87..7b46bab0 100644 --- a/content_scripts/scroller.coffee +++ b/content_scripts/scroller.coffee @@ -77,12 +77,14 @@ doesScroll = (element, direction, amount, factor) ->    delta = getSign delta # 1 or -1    performScroll(element, direction, delta) and performScroll(element, direction, -delta) +isScrollableElement = (element, direction = "y", amount = 1, factor = 1) -> +  doesScroll(element, direction, amount, factor) and shouldScroll element, direction +  # From element and its parents, find the first which we should scroll and which does scroll.  findScrollableElement = (element, direction, amount, factor) -> -  while element != document.body and -    not (doesScroll(element, direction, amount, factor) and shouldScroll(element, direction)) -      element = (DomUtils.getContainingElement element) ? document.body -  if element == document.body then firstScrollableElement element else element +  while element != document.body and not isScrollableElement element, direction, amount, factor +    element = DomUtils.getContainingElement(element) ? document.body +  element  # On some pages, document.body is not scrollable.  Here, we search the document for the largest visible  # element which does scroll vertically. This is used to initialize activatedElement. See #1358. @@ -257,6 +259,9 @@ Scroller =      amount = getDimension(element,direction,pos) - element[scrollProperties[direction].axisName]      CoreScroller.scroll element, direction, amount +  isScrollableElement: (element) -> +    isScrollableElement element +    # Scroll the top, bottom, left and right of element into view.  The is used by visual mode to ensure the    # focus remains visible.    scrollIntoView: (element) -> | 
