       (scope, element, attr) ->
         actor = rekapi.addActor({ context: element[0] })
         y = 0
+        prevScrollY = 0
         scrollY = 0
         animationFrame = new AnimationFrame()
         updating = false


        actionsUpdate = ->

          d = scrollY - y

          if d<0 and actionFrameIdx >= 0  # scroll up: don't apply on page load (only apply on page load for downward movement)
            idx = if (actionFrameIdx >= actionFrames.length) then actionFrameIdx-1 else actionFrameIdx


          actionFrames.sort (a,b) -> a > b

          y = prevScrollY = scrollY = $window.scrollY
          update()
          actionsUpdate()
        , true  # deep watch
