     $el.attr 'style', "position: -webkit-sticky; position: sticky; top: #{@viewportTop()}px"
 
   headerHeight: ->
-    $('#main-layout-header').height()
+    (@$header ?= $('#main-layout-header')).height()
 
   visibleArea: ->
     @$window.height() - @headerHeight()

    @$window = $(window)
    @$document = $(document)

    return if Stickyfill?
    require './vendor/stickyfill.js'

    # rebuild the sticky menu when ajax events stop firing
    # defer to wait after render
    @$document.on 'ajaxStop', => _.defer => @rebuild()

  add: ($el) ->
    _.defer =>

    if isTouchDevice() then 0 else @headerHeight()

  rebuild: ->
    return unless Stickyfill?

    top = @viewportTop()
    Stickyfill.stickies.map (sticky) =>
      sticky.css.top = top
      $(sticky.node).css 'top', top

    Stickyfill.rebuild()
