   return
 
 
-
-###*
-# `touchmove` handler for scrollable view.
-#
-#
+###*
+# The scroll movement handler. This method handled `touchmove` or `wheel`
+# events.
+#
+# @param {Event} e - The movement event.
+#
+# @function onMove
 ###
 onMove = (e) ->
   if scrolling

  return



onWheel = (e) ->
  if wheelTimer then clearTimeout wheelTimer

  if not scrolling then startScrolling.call @, e

  wheelTimer = setTimeout ->
    stopScrolling()
  , WHEEL_TIME

  onMove.call @, e



elastic = (y, limit) ->
  # * x = distance from the edge
  # * c = constant value, UIScrollView uses 0.55

scrolling = false


###*
# Timer used for stopping scroll wheel initated scrolls.
#
#
###
wheelTimer = null


###*
# The time to wait before ending a scroll initiated by the scroll wheel.
#
# @const {number}
# @inner
###
WHEEL_TIME = 100


###*
# Maximum scrollable height.
#
# @type number
###
max = Infinity


###*
# The minimum offset.
#
# @type number
###
min = 0


###*
# The scrollable view's current translation offset.
#
# @type number
###
offset = 0


###*
# The reference 'y' position, used between scroll events to track the distance
# scrolled.
#
# @type number
# @inner
###
reference = 0


###*
# The calculated height of the scrollable view.
#
# @type number
# @inner
###
refHeight = 0


###*
# Start the view scrolling.
#
# @param {Event} e - The event which started scroll.
#
# @function startScrolling
# @inner
###
startScrolling = (e) ->
  scrolling = true
  reference = ypos e
  refHeight = parseInt(getComputedStyle(@root.firstChild).height)
  max = refHeight - window.innerHeight
  return


###*
# Stops view scrolling.
#
# @function stopScrolling
# @inner
###
stopScrolling = ->
  scrolling = false


###*
# `touchstart` handler starts scrolls initiated by a touch event.
#
# @param {TouchEvent} e - The touch event which initated the scroll.
#
# @function onTouchStart
###
onTouchStart = (e) ->
  startScrolling.call @, e
