     @$heroUnits = @$('.home-hero-unit')
 
     @setBodyClass()
-    @setInterval()
+    @initInterval()
 
     @$window.on 'scroll', _.throttle @setBodyClass, 100
     @$window.on 'keyup', (e) => @onKeyUp(e)

_ = require 'underscore'
Backbone = require 'backbone'
imagesLoaded = require 'imagesloaded'

module.exports = class HeroUnitView extends Backbone.View
  events:
    'click #home-hero-units-left-arrow': 'onLeftArrow'
    'click #home-hero-units-right-arrow': 'onRightArrow'
    'click #home-hero-unit-dots li': 'onDot'

  initialize: ->
    @$window = $(window)

        .height($(this).height())
        .attr 'src', $(this).attr('data-retina')

  initInterval: ->
    if CURRENT_USER? then @setInterval else _.delay(@setInterval, @pauseLength)

  setInterval: =>
    clearInterval @interval
    @interval = setInterval @nextHeroUnit, @pauseLength

  setBodyClass: =>
    if @$window.scrollTop() + @$mainHeader.height() <= @$heroUnitsContainer.height()
