     duration = Math.max 100, 20 * Math.log amount
 
     totalDelta = 0
+    totalElapsed = 0.0
     calibration = 1.0
-    initialTimestamp = null
     previousTimestamp = null
     animatorId = null
 
-    progressAnimation = ->
+    advanceAnimation = ->
       animatorId = requestAnimationFrame animate
 
     cancelAnimation = ->
-      # Make one final call of performScroll to check the visibility of the activated element.
-      performScroll element, axisName, 0, true
       cancelAnimationFrame animatorId
 
     animate = (timestamp) ->
-      initialTimestamp ?= timestamp
       previousTimestamp ?= timestamp
 
       if timestamp == previousTimestamp
-        return progressAnimation()
+        return advanceAnimation()
 
       # The elapsed time is typically about 16ms.
       elapsed = timestamp - previousTimestamp
-      totalElapsed = timestamp - initialTimestamp
+      totalElapsed += elapsed
       previousTimestamp = timestamp
 
       # The constants in the duration calculation, above, are chosen to provide reasonable scroll speeds for

  else
    amount

# Test whether element should be scrolled.
shouldScroll = (element, direction) ->
  computedStyle = window.getComputedStyle(element)

      element = element.parentElement || document.body
  element

checkVisibility = (element) ->
  # if the activated element has been scrolled completely offscreen, subsequent changes in its scroll
  # position will not provide any more visual feedback to the user. therefore we deactivate it so that
  # subsequent scrolls only move the parent element.
  rect = activatedElement.getBoundingClientRect()
  if (rect.bottom < 0 || rect.top > window.innerHeight || rect.right < 0 || rect.left > window.innerWidth)
    activatedElement = element

# How scrolling is handled:
#   - For non-smooth scrolling, the entire scroll happens immediately.
