     name = amount
     # the clientSizes of the body are the dimensions of the entire page, but the viewport should only be the
     # part visible through the window
-    if name is 'viewSize' and el is document.body
+    if name is 'viewSize' and el is document.scrollingElement
       # TODO(smblott) Should we not be returning the width/height of element, here?
       if direction is 'x' then window.innerWidth else window.innerHeight
     else


  # Is element scrollable and not the activated element?
  isScrollableElement: (element) ->
    activatedElement ||= (document.body and firstScrollableElement()) or document.body
    element != activatedElement and 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) ->
    activatedElement ||= document.body and firstScrollableElement()
    rect = element. getClientRects()?[0]
    if rect?
      # Scroll y axis.

  # :factor is needed because :amount can take on string values, which scrollBy converts to element dimensions.
  scrollBy: (direction, amount, factor = 1, continuous = true) ->
    # if this is called before domReady, just use the window scroll function
    if (!document.scrollingElement and amount instanceof Number)
      if (direction == "x")
        window.scrollBy(amount, 0)
      else
        window.scrollBy(0, amount)
      return

    activatedElement ||= (document.scrollingElement and firstScrollableElement()) or document.scrollingElement
    return unless activatedElement

    # Avoid the expensive scroll calculation if it will not be used.  This reduces costs during smooth,
