#= require ./behavior

class window.ScrollTo extends window.Behavior
  init: ->
    @$target = @domData('scroll-target')
    @$dom.click =>
      @scrollTo()

  flare: =>
    originalColor = @$target.css('background-color')
    @$target.animate(
      backgroundColor: "#FCF8E3"
    , 600).animate(
      backgroundColor: originalColor
    , 600)

  scrollTo: ->
    self = @
    $('body').scrollTo(@$target, 500,
      onAfter: self.flare
    )
