@@ -41,28 +41,40 @@ class exports.LayerPinchable extends BaseClass
@layer .on (Gestures .PinchStart , @_pinchStart )
@layer .on (Gestures .Pinch , @_pinch )
@layer .on (Gestures .PinchEnd , @_pinchEnd )
@layer .on (Gestures .TapStart , @_tapStart )
_reset : ->
@_scaleStart = null
@_rotationStart = null
@_rotationOffset = null
_pinchStart : (event ) =>
_tapStart : (event ) ->
# @_centerOrigin(event) if @centerOrigin
@ _reset ()
_centerOrigin : (event ) =>
topInSuperBefore = Utils .convertPoint ({}, @layer , @layer .superLayer )
pinchLocation = Utils .convertPointFromContext (event .touchCenter , @layer , true , true )
@layer .originX = pinchLocation .x / @layer .width
@layer .originY = pinchLocation .y / @layer .height
if @centerOrigin
topInSuperAfter = Utils .convertPoint ({}, @layer , @layer .superLayer )
xDiff = topInSuperAfter .x - topInSuperBefore .x
yDiff = topInSuperAfter .y - topInSuperBefore .y
@layer .x -= xDiff
@layer .y -= yDiff
topInSuperBefore = Utils .convertPoint ({}, @layer , @layer .superLayer )
pinchLocation = Utils .convertPointFromContext (event .touchCenter , @layer , true , true )
@layer .originX = pinchLocation .x / @layer .width
@layer .originY = pinchLocation .y / @layer .height
# This is not a great fix, we should add this in the draggable. Basically
# we need to account in the draggable for a change of origin relative to
# the dragging start offset.
if @layer ._draggable
@layer .draggable ._layerStartPoint .x -= xDiff
@layer .draggable ._layerStartPoint .y -= yDiff
topInSuperAfter = Utils .convertPoint ({}, @layer , @layer .superLayer )
xDiff = topInSuperAfter .x - topInSuperBefore .x
yDiff = topInSuperAfter .y - topInSuperBefore .y
@layer .x -= xDiff
@layer .y -= yDiff
_pinchStart : (event ) =>
@ _reset ()
@ _centerOrigin (event) if @centerOrigin
_pinch : (event ) =>
@jonastreub this is the fix! Do you have a good idea how we could add this to the draggable? Basically we need to store the start origin and correct the start offset if we notice the origin has been changed.