 ###
 refHeight = 0
 
+
+velocity = 0
+
+amplitude = 0
+
+frame = 0
+
+target = 0
+
+scrollTimestamp = null
+
+scrollTicker = null
+
+TICK_INTERVAL = 30
+
+T_CONST = 325
 
 ###*
 # Start the view scrolling.

###
onTouchStart = (e) ->
  startScrolling.call @, e
  e.preventDefault()
  e.stopPropagation()
  return

  scrolling = false



stopKineticScrolling = ->
  clearInterval scrollTicker
  if Math.abs(velocity) > 10
    amplitude = 0.8 * velocity
    target = Math.round(offset + amplitude)
    scrollTimestamp = Date.now()
    requestAnimationFrame => autoScroll.call @


autoScroll = ->
  if amplitude
    elapsed = Date.now() - scrollTimestamp
    delta = -amplitude * Math.exp(-elapsed / T_CONST)
    if Math.abs(delta) > 0.5
      console.log target, delta, target + delta
      scroll.call @, target + delta
      requestAnimationFrame => autoScroll.call @
    else
      scroll.call @, target


###*
# `touchstart` handler starts scrolls initiated by a touch event.
#
