diff options
| author | Stephen Blott | 2018-09-04 11:07:52 +0100 |
|---|---|---|
| committer | Stephen Blott | 2018-09-04 11:07:52 +0100 |
| commit | f86e611e1a1cb87cd5b6757fb0000c9342b5b4c3 (patch) | |
| tree | 98c740d444c8a912bda1b32d54f177d121562830 | |
| parent | 299c3684ceec423e3c7b405ef629b441efb1f336 (diff) | |
| parent | 72aaf054201755f837ba84f26a4d74846a81ffba (diff) | |
| download | vimium-f86e611e1a1cb87cd5b6757fb0000c9342b5b4c3.tar.bz2 | |
Merge branch 'marcotc--new-reddit-scroll'
| -rw-r--r-- | content_scripts/scroller.coffee | 24 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 1 |
2 files changed, 15 insertions, 10 deletions
diff --git a/content_scripts/scroller.coffee b/content_scripts/scroller.coffee index 7202c682..94a0d4f1 100644 --- a/content_scripts/scroller.coffee +++ b/content_scripts/scroller.coffee @@ -9,7 +9,7 @@ activatedElement = null # https://github.com/philc/vimium/pull/2168#issuecomment-236488091 getScrollingElement = -> - document.scrollingElement ? document.body + getSpecialScrollingElement() ? document.scrollingElement ? document.body # Return 0, -1 or 1: the sign of the argument. # NOTE(smblott; 2014/12/17) We would like to use Math.sign(). However, according to this site @@ -248,6 +248,10 @@ Scroller = # yet implemented by Chrome. activatedElement = event.deepPath?[0] ? event.path?[0] ? event.target CoreScroller.init() + @reset() + + reset: -> + activatedElement = null # scroll the active element in :direction by :amount * :factor. # :factor is needed because :amount can take on string values, which scrollBy converts to element dimensions. @@ -309,15 +313,15 @@ Scroller = element = findScrollableElement element, "x", amount, 1 CoreScroller.scroll element, "x", amount, false -# Hack to make expanded tweets scrollable on Twitter (See #3045). -if DomUtils.isTopFrame() and window.location.host == "twitter.com" - for method in ["scrollTo", "scrollBy"] - do -> - func = Scroller[method] - Scroller[method] = -> - element = document.querySelector "div.permalink-container div.permalink[role=main]" - activatedElement = element ? getScrollingElement() - func arguments... +getSpecialScrollingElement = -> + selector = specialScrollingElementMap[window.location.host] + if selector + document.querySelector selector + +specialScrollingElementMap = + 'twitter.com': 'div.permalink-container div.permalink[role=main]' + 'reddit.com': '#overlayScrollContainer' + 'new.reddit.com': '#overlayScrollContainer' root = exports ? (window.root ?= {}) root.Scroller = Scroller diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 26aa3492..6fa118cf 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -307,6 +307,7 @@ checkIfEnabledForUrl = do -> # When we're informed by the background page that a URL in this tab has changed, we check if we have the # correct enabled state (but only if this frame has the focus). checkEnabledAfterURLChange = forTrusted -> + Scroller.reset() # The URL changing feels like navigation to the user, so reset the scroller (see #3119). checkIfEnabledForUrl() if windowIsFocused() # If we are in the help dialog iframe, then HelpDialog is already defined with the necessary functions. |
