Permalink
Browse files

fix origin when pinch starts

  • Loading branch information...
J.P.P Treub
J.P.P Treub committed Jan 21, 2016
1 parent 56b653a commit f985fbbc04ae74298f76be64213d83adc98b75d5
Showing with 12 additions and 4 deletions.
  1. +12 −4 framer/LayerPinchable.coffee
@@ -34,7 +34,6 @@ class exports.LayerPinchable extends BaseClass
constructor: (@layer) ->
super
@_attach()
_attach: ->
@@ -53,6 +52,18 @@ class exports.LayerPinchable extends BaseClass
@emit(Events.ScaleStart, event) if @scale
@emit(Events.RotateStart, event) if @rotate
if @setOrigin
topInSuperBefore = Utils.convertPoint({}, @layer, @layer.superLayer)
pinchLocation = Utils.convertPointFromContext(event.center, @layer, true, true)
@layer.originX = pinchLocation.x / @layer.width
@layer.originY = pinchLocation.y / @layer.height
topInSuperAfter = Utils.convertPoint({}, @layer, @layer.superLayer)
xDiff = topInSuperAfter.x - topInSuperBefore.x
yDiff = topInSuperAfter.y - topInSuperBefore.y
@layer.x -= xDiff
@layer.y -= yDiff
_pinchMove: (event) =>
return unless event.pointers.length is 2
@@ -68,9 +79,6 @@ class exports.LayerPinchable extends BaseClass
return unless Utils.pointTotal(Utils.pointAbs(Utils.pointSubtract(pointA, pointB))) > @threshold
# TODO
# if @setOrigin
if @scale
@_scaleStart ?= @layer.scale
scale = event.scale * @_scaleStart

0 comments on commit f985fbb

Please sign in to comment.