@@ -89,8 +89,9 @@ isScrollableElement = (element, direction = "y", amount = 1, factor = 1) ->
89
89
90
90
# From element and its parents, find the first which we should scroll and which does scroll.
91
91
findScrollableElement = (element , direction , amount , factor ) ->
92
- while element != getScrollingElement () and not isScrollableElement element, direction, amount, factor
92
+ while not isScrollableElement element, direction, amount, factor
93
93
element = DomUtils .getContainingElement (element) ? getScrollingElement ()
94
+ return element if element == getScrollingElement () # Prevent infinite loop.
94
95
element
95
96
96
97
# On some pages, the scrolling element is not actually scrollable. Here, we search the document for the
@@ -102,7 +103,7 @@ firstScrollableElement = (element = null) ->
102
103
if doesScroll (scrollingElement, " y" , 1 , 1 ) or doesScroll (scrollingElement, " y" , - 1 , 1 )
103
104
return scrollingElement
104
105
else
105
- element = document . body ? getScrollingElement ()
106
+ element = getScrollingElement () ? document . body
106
107
107
108
if doesScroll (element, " y" , 1 , 1 ) or doesScroll (element, " y" , - 1 , 1 )
108
109
element
@@ -322,6 +323,7 @@ specialScrollingElementMap =
322
323
' twitter.com' : ' div.permalink-container div.permalink[role=main]'
323
324
' reddit.com' : ' #overlayScrollContainer'
324
325
' new.reddit.com' : ' #overlayScrollContainer'
326
+ ' mail.google.com' : ' table[role="presentation"]'
325
327
326
328
root = exports ? (window .root ?= {})
327
329
root .Scroller = Scroller
0 commit comments