 class Turbolinks.ProgressBar
-  DELAY = 300
+  ANIMATION_DURATION = 300
 
   @defaultCSS: """
     .turbolinks-progress-bar {

      height: 3px;
      background: #0076ff;
      z-index: 9999;
      transition: width #{DELAY}ms ease-out, opacity #{DELAY / 2}ms #{DELAY / 2}ms ease-in;
      transform: translate3d(0, 0, 0);
    }
  """


  fadeProgressElement: (callback) ->
    @progressElement.style.opacity = 0
    setTimeout(callback, ANIMATION_DURATION * 1.5)

  uninstallProgressElement: ->
    document.documentElement.removeChild(@progressElement)

  startTrickling: ->
    @trickleInterval ?= setInterval(@trickle, ANIMATION_DURATION)

  stopTrickling: ->
    clearInterval(@trickleInterval)
