Skip to content
Permalink
Browse files

Fix SliderComponent

  • Loading branch information...
Koen Bok
Koen Bok committed Feb 3, 2016
1 parent 267cd7e commit 4795a1b8fdcf0244179d44c92614cb862d25f85f
Showing with 18 additions and 9 deletions.
  1. +14 −5 framer/Components/SliderComponent.coffee
  2. +4 −4 framer/LayerDraggable.coffee
@@ -79,7 +79,6 @@ class exports.SliderComponent extends Layer
@knob.draggable.momentum = true
@knob.draggable.momentumOptions = {friction: 5, tolerance: 0.25}
@knob.draggable.bounce = false
@knob.draggable.propagateEvents = false
@knob.borderRadius = @knobSize / 2
@knobOverlay.borderRadius = (@knob.borderRadius * 2) + (@hitArea / 4)

@@ -111,12 +110,14 @@ class exports.SliderComponent extends Layer
@_updateValue()

# On click/touch of the slider, update the value
@on(Events.TouchStart, @_touchDown)
@sliderOverlay.on(Events.TouchStart, @_touchDown)
# @on(Events.TouchStart, @_touchDown)

_touchDown: (event) =>
@on(Events.TapStart, @_touchStart)
@on(Events.Pan, @_touchMove)
@on(Events.TapEnd, @_touchEnd)

_touchStart: (event) =>
event.preventDefault()
event.stopPropagation()

offsetX = (@min / @canvasScaleX()) - @min
offsetY = (@min / @canvasScaleY()) - @min
@@ -129,6 +130,14 @@ class exports.SliderComponent extends Layer
@knob.draggable._touchStart(event)
@_updateValue()

_touchMove: (event) =>
if event.target is @_element
@knob.draggable._touchMove(event)

_touchEnd: (event) =>
if event.target is @_element
@knob.draggable._touchEnd(event)

_updateFill: =>
if @width > @height
@fill.width = @knobOverlay.midX = @knob.midX
@@ -130,7 +130,7 @@ class exports.LayerDraggable extends BaseClass
@_resetdirectionLock()

event.preventDefault()
event.stopPropagation() unless @propagateEvents
event.stopPropagation() if @propagateEvents is false

# Extract the event (mobile may have multiple)
touchEvent = Events.touchEvent(event)
@@ -167,13 +167,13 @@ class exports.LayerDraggable extends BaseClass
@emit(Events.DragStart, event)

_touchMove: (event) =>

return unless @enabled

@_lastEvent = event

event.preventDefault()
event.stopPropagation() unless @propagateEvents
event.stopPropagation() if @propagateEvents is false

touchEvent = Events.touchEvent(event)

@@ -231,7 +231,7 @@ class exports.LayerDraggable extends BaseClass

_touchEnd: (event) =>

event.stopPropagation() unless @propagateEvents
event.stopPropagation() if @propagateEvents is false

# Start the simulation prior to emitting the DragEnd event.
# This way, if the user calls layer.animate on DragEnd, the simulation will

0 comments on commit 4795a1b

Please sign in to comment.
You can’t perform that action at this time.