Permalink
Browse files

Fixing slider calculations for dpr changes

  • Loading branch information...
nvh committed Oct 9, 2017
1 parent b274bf2 commit 0524216bbd1018ce4b2939653ad33d6ea434ab18
Showing with 6 additions and 10 deletions.
  1. +2 −5 framer/Components/RangeSliderComponent.coffee
  2. +4 −5 framer/Components/SliderComponent.coffee
@@ -103,11 +103,8 @@ class exports.RangeSliderComponent extends Layer
_touchStart: (event) =>
event.preventDefault()
offsetX = (@min / @canvasScaleX()) - @min
offsetY = (@min / @canvasScaleY()) - @min
if @width > @height
clickedValue = @valueForPoint(Events.touchEvent(event).clientX - @screenScaledFrame().x) / @canvasScaleX() - offsetX
clickedValue = @valueForPoint((Events.touchEvent(event).clientX / @canvasScaleX()) - @screenScaledFrame().x)
if clickedValue > @maxValue
@maxValue = clickedValue
@@ -120,7 +117,7 @@ class exports.RangeSliderComponent extends Layer
@emit(Events.SliderMinValueChange, @minValue)
else
clickedValue = @valueForPoint(Events.touchEvent(event).clientY - @screenScaledFrame().y) / @canvasScaleY() - offsetY
clickedValue = @valueForPoint((Events.touchEvent(event).clientY / @canvasScaleY()) - @screenScaledFrame().y)
if clickedValue > @maxValue
@maxValue = clickedValue
@@ -93,13 +93,12 @@ class exports.SliderComponent extends Layer
_touchStart: (event) =>
event.preventDefault()
offsetX = (@min / @canvasScaleX()) - @min
offsetY = (@min / @canvasScaleY()) - @min
if @width > @height
@value = @valueForPoint(Events.touchEvent(event).clientX - @screenScaledFrame().x) / @canvasScaleX() - offsetX
scaleX = @canvasScaleX()
@value = @valueForPoint((Events.touchEvent(event).clientX / scaleX) - @screenScaledFrame().x)
else
@value = @valueForPoint(Events.touchEvent(event).clientY - @screenScaledFrame().y) / @canvasScaleY() - offsetY
scaleY = @canvasScaleY()
@value = @valueForPoint((Events.touchEvent(event).clientY / scaleY) - @screenScaledFrame().y)
@knob.draggable._touchStart(event)
@_updateValue()

0 comments on commit 0524216

Please sign in to comment.