     options.drawBar    ?= yes
     options.showLabels ?= yes
     options.snap       ?= yes
+    options.snapOnDrag ?= no
     options.width     or= 300
 
     super options, data

    @drawBar()   if @getOption('drawBar')
    @addLabels() if @getOption('showLabels')
    @attachEvents()

class KDSliderBarHandleView extends KDCustomHTMLView
  constructor:(options = {}, data = {})->
    options.tagName   = "a"
    options.cssClass  = "handle"
    data.value       ?= 0
    options.draggable =
      axis            : "x"

    super options, data

  attachEvents:->
    {maxValue, minValue, width} = @parent.getOptions()
    {value}                     = @getData()

    @on "DragStarted", ->
      value = @getData().value
    @on "DragInAction", ->
      relPos       = @dragState.position.relative.x
      valueChange  = ((maxValue-minValue)*relPos)/width
      @setValue value+valueChange
    @on "DragFinished", ->
      @snap() if @parent.getOption "snap"

  getPosition:->
    {maxValue, minValue} = @parent.getOptions()
    {value}              = @getData()
    sliderWidth          = @parent.getWidth()

    percentage = ((value-minValue)*100)/(maxValue-minValue)
    position   = (sliderWidth/100)*percentage

    return "#{position}px"

  setValue:(value)->
    {leftLimit, rightLimit} = @getData()

    if !(value<leftLimit) and !(value>rightLimit)
      @data.value = value
    
    else if value > rightLimit
      @data.value = rightLimit

    else if value < leftLimit
      @data.value = leftLimit

    @setX "#{@getPosition()}"
    @parent.drawBar() if @parent.getOption('drawBar')

      
  getSnappedValue:(value)->
    {interval}  = @parent.getOptions()
    {value}     = value or @getOptions()
    
    if interval
      mod = value % interval
      mid = interval / 2

      return value = switch
        when mod <= mid then value - mod
        when mod >  mid then value + (interval - mod)
        else value

  snap:->
    {interval}  = @parent.getOptions()
    value       = @getSnappedValue()

    if interval and @parent.getOption "snap"
      @setValue value
      @parent.drawBar() if @parent.getOption('drawBar')

  viewAppended:->
    @setX "#{@getPosition()}"
    @attachEvents()
    @snap() if @parent.getOption "snap"