Permalink
Browse files

Merge branch 'master' of github.com:koenbok/Framer

  • Loading branch information...
koenbok committed May 21, 2015
2 parents 9f69cd4 + 623ae9c commit 6bb20383ce0319e5e9706e48e0df29e41542e608
Showing with 15 additions and 10 deletions.
  1. +1 −1 extras/Studio.framer/framer/config.json
  2. +14 −9 framer/Components/SliderComponent.coffee
@@ -3,7 +3,7 @@
"sharedPrototype" : 1,
"deviceOrientation" : 0,
"contentScale" : 1,
"deviceType" : "iphone-6-silver",
"deviceType" : "fullscreen",
"updateDelay" : 0.3,
"deviceScale" : -1,
"delay" : 0.3
@@ -25,7 +25,8 @@ class exports.SliderComponent extends Layer
options.clip ?= false
options.width ?= 300
options.height ?= 10
options.value ?= 0
@knob = new Layer
backgroundColor: "#fff"
shadowY: 1, shadowBlur: 3
@@ -53,26 +54,30 @@ class exports.SliderComponent extends Layer
@knob.borderRadius = "50%"
@_updateFrame()
@_updateKnob()
@_updateFill()
@on("change:frame", @_updateFrame)
@on("change:size", @_updateFrame)
@on("change:borderRadius", @_setRadius)
@knob.on("change:x", @_updateFill)
@knob.on("change:x", @_updateValue)
@knob.on("change:size", @_updateKnob)
@knob.on(Events.DragMove, @_updateFrame)
# On click/touch of the slider, update the value
@on(Events.TouchStart, @_touchDown)
@knob.on Events.Move, =>
@_updateFrame()
@_updateValue()
# On click/touch of the slider, update the value
@on(Events.TouchStart, @_touchDown)
_touchDown: (event) =>
event.preventDefault()
event.stopPropagation()
offsetX = (@min / @canvasScaleX()) - @min
@value = @valueForPoint(event.x - @screenScaledFrame().x) / @canvasScaleX() - offsetX
@value = @valueForPoint(Events.touchEvent(event).clientX - @screenScaledFrame().x) / @canvasScaleX() - offsetX
@knob.draggable._touchStart(event)
@_updateValue()
_updateFill: =>
@fill.width = @knob.midX
@@ -84,9 +89,9 @@ class exports.SliderComponent extends Layer
_updateFrame: =>
@knob.draggable.constraints =
x: -@knob.width / 2
y: -@knob.height / 2
width: @width + @knob.width
# y: -@knob.height / 2
# height: @height + @knob.height
height: @height + @knob.height
@fill.height = @height
@knob.centerY()

0 comments on commit 6bb2038

Please sign in to comment.