     amount
 
 # Perform a scroll. Return true if we successfully scrolled by the requested amount, and false otherwise.
-performScroll = (element, axisName, amount) ->
+performScroll = (element, direction, amount) ->
+  axisName = scrollProperties[direction].axisName
   before = element[axisName]
   element[axisName] += amount
   amount == element[axisName] - before

      delta = Math.ceil amount * (elapsed / duration) * calibration
      delta = if isKeyStillDown() then delta else Math.max 0, Math.min delta, amount - totalDelta

      if delta and performScroll element, axisName, sign * delta
        totalDelta += delta
        advanceAnimation()
      else
        checkVisibility element
        cancelAnimationFrame animatorId

    advanceAnimation()


  (element, direction, amount) ->
    return unless amount

    keyHandler ?= handlerStack.push
      keydown: -> lastEvent = event
      keyup: -> time += 1

    unless settings.get "smoothScroll"
      # Jump scrolling.
      performScroll element, direction, amount
      checkVisibility element
      return

