@@ -9,7 +9,7 @@ activatedElement = null
99# https://github.com/philc/vimium/pull/2168#issuecomment-236488091
1010
1111getScrollingElement = ->
12- document .scrollingElement ? document .body
12+ getSpecialScrollingElement () ? document .scrollingElement ? document .body
1313
1414# Return 0, -1 or 1: the sign of the argument.
1515# NOTE(smblott; 2014/12/17) We would like to use Math.sign(). However, according to this site
@@ -248,6 +248,10 @@ Scroller =
248248 # yet implemented by Chrome.
249249 activatedElement = event .deepPath ? [0 ] ? event .path ? [0 ] ? event .target
250250 CoreScroller .init ()
251+ @ reset ()
252+
253+ reset : ->
254+ activatedElement = null
251255
252256 # scroll the active element in :direction by :amount * :factor.
253257 # :factor is needed because :amount can take on string values, which scrollBy converts to element dimensions.
@@ -309,15 +313,15 @@ Scroller =
309313 element = findScrollableElement element, " x" , amount, 1
310314 CoreScroller .scroll element, " x" , amount, false
311315
312- # Hack to make expanded tweets scrollable on Twitter (See #3045).
313- if DomUtils . isTopFrame () and window .location .host == " twitter.com "
314- for method in [ " scrollTo " , " scrollBy " ]
315- do ->
316- func = Scroller[method]
317- Scroller[method] = ->
318- element = document . querySelector " div.permalink-container div.permalink[role=main]"
319- activatedElement = element ? getScrollingElement ()
320- func arguments ...
316+ getSpecialScrollingElement = ->
317+ selector = specialScrollingElementMap[ window .location .host ]
318+ if selector
319+ document . querySelector selector
320+
321+ specialScrollingElementMap =
322+ ' twitter.com ' : ' div.permalink-container div.permalink[role=main]'
323+ ' reddit.com ' : ' #overlayScrollContainer '
324+ ' new.reddit.com ' : ' #overlayScrollContainer '
321325
322326root = exports ? (window .root ?= {})
323327root .Scroller = Scroller
0 commit comments