aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content_scripts/scroller.coffee9
-rw-r--r--content_scripts/vimium_frontend.coffee2
2 files changed, 7 insertions, 4 deletions
diff --git a/content_scripts/scroller.coffee b/content_scripts/scroller.coffee
index 19bf91cf..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 = ->
- specialScrollingElement() ? 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
@@ -239,7 +239,6 @@ CoreScroller =
# Scroller contains the two main scroll functions which are used by clients.
Scroller =
init: ->
- activatedElement = null
handlerStack.push
_name: 'scroller/active-element'
DOMActivate: (event) -> handlerStack.alwaysContinueBubbling ->
@@ -249,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.
@@ -310,7 +313,7 @@ Scroller =
element = findScrollableElement element, "x", amount, 1
CoreScroller.scroll element, "x", amount, false
-specialScrollingElement = ->
+getSpecialScrollingElement = ->
selector = specialScrollingElementMap[window.location.host]
if selector
document.querySelector selector
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index e93a7ad9..6fa118cf 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -297,7 +297,6 @@ checkIfEnabledForUrl = do ->
{isEnabledForUrl, passKeys, frameIsFocused, isFirefox} = response
Utils.isFirefox = -> isFirefox
installModes() unless normalMode
- Scroller.init() # TODO hack to bust Scroller.activatedElement caching
normalMode.setPassKeys passKeys
# Hide the HUD if we're not enabled.
HUD.hide true, false unless isEnabledForUrl
@@ -308,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.