     false;
 
   isInertia: (direction) ->
+    # Get the relevant last*Delta array
     lastDeltas = if direction == -1 then @lastDownDeltas else @lastUpDeltas
+
+    # If the array is not filled up yet, we cannot compare averages, so assume the scroll event to be intentional
     if lastDeltas[0] == null
       return direction
+
+    # If the last mousewheel occurred within 150 miliseconds of the penultimate one, and their values are the same. We will assume that this is a trackpad with a constant profile, and will return false
     if @deltasTimestamp[(this.stability * 2) - 2] + 150 > Date.now() and lastDeltas[0] == lastDeltas[(@stability * 2) - 1]
       return false
+
+    # Check to see if the new rolling average (based on the last half of the lastDeltas array) is significantly higher than the old rolling average. If so return direction, else false
     lastDeltasOld = lastDeltas.slice(0, @stability)
     lastDeltasNew = lastDeltas.slice(@stability, (@stability * 2))
 


class root.Lethargy
  constructor: (stability, sensitivity, tolerance) ->
    @stability = if stability? then Math.abs stability else 8
    @sensitivity = if sensitivity? then 1 + Math.abs sensitivity else 100
    @tolerance = if tolerance? then 1 + Math.abs tolerance else 1.1
    @lastUpDeltas = (null for [1..(@stability * 2)])
    @lastDownDeltas = (null for [1..(@stability * 2)])
    @deltasTimestamp = (null for [1..(@stability * 2)])

  check: (e) ->
    e = e.originalEvent || e
    if e.wheelDelta?
      lastDelta = e.wheelDelta
    else if e.deltaY?

    else if (e.detail? or e.detail == 0)
      lastDelta = e.detail * -40

    # Add the new event timestamp to deltasTimestamp array, and remove the oldest entry
    @deltasTimestamp.push(Date.now())
    @deltasTimestamp.shift()

    # If lastDelta is positive, it means the user scrolled up
    if (lastDelta > 0)
      @lastUpDeltas.push(lastDelta)
      @lastUpDeltas.shift()
      return @isInertia(1)
    # Otherwise, the user scrolled down
    else
      @lastDownDeltas.push(lastDelta)
      @lastDownDeltas.shift()
