 
   getDefaultProps: ->
     buffer: 60
+    scrollSpeedBuffer: 20
+
+  getInitialState: ->
+    pinned: false
 
   mixins: [ScrollListenerMixin]
 

      'add' # add class if shouldPinHeader is true
    ]

    shouldPinHeader = @shouldPinHeader(@state.scrollTop) * 1
    classAction = addOrRemove[shouldPinHeader]
    document.body.classList[classAction]('pinned-on')


  componentWillUnmount: ->
    document.body.classList.remove(@documentBodyClass)

  isScrollingSlowed: (prevScrollTop, currentScrollTop) ->
    Math.abs(prevScrollTop - currentScrollTop) <= @props.scrollSpeedBuffer

  isScrollingUp: (prevScrollTop, currentScrollTop) ->
    (prevScrollTop - currentScrollTop) > @props.scrollSpeedBuffer

  shouldPinHeader: (prevScrollTop, currentScrollTop) ->
    if @isScrollingSlowed(prevScrollTop, currentScrollTop)
      # keep as previous pinned state
      shouldPinHeader = @state.pinned
    else if @isScrollingUp(prevScrollTop, currentScrollTop)
      # unpinned on upscroll
      shouldPinHeader = false
    else
      # otherwise, on down scroll, check if the scroll position is past buffer
      shouldPinHeader = (currentScrollTop > @props.buffer)

    shouldPinHeader

  shouldComponentUpdate: (nextProps, nextState) ->
    # ignore scrolling state changes when checking should component update
