This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Stephen Etheredge
Posted Nov 12 - Read on Facebook

How can I set my draggable constraint proportions once I already zoomed in and the base layer is scaled * 2???

6 Comments

Pawel Kontek

Stephen Etheredge I am having the same problem. Did you find a solution? :)

Koen Bok

These are really hard to answer without a small example I'm afraid. If I had to make a wild guess I think you would have to account the constraints for scale (so * 2 everything) and optionally account for the origin (which influences the position with scale).

Stephen Etheredge

it's the origin part that is tricky

Stephen Etheredge

will upload a small version of the prototype

Stephen Etheredge

Screen.backgroundColor = "#fff"

base = new Layer
x: 0
y: 0
width: Screen.width
height: Screen.height
backgroundColor: '#f2f2f3'

testSize = 100
test = new Layer
parent: base
x: (Screen.width / 2) - (testSize /2)
y: (Screen.height / 2) - (testSize /2)
backgroundColor: 'red'
width: testSize
height: testSize

# pinch settings
base.pinchable.rotate = false
base.pinchable.enabled = true
base.pinchable.centerOrigin = true
base.pinchable.minScale = 1
base.pinchable.maxScale = 2.1

# drag settings
base.draggable.enabled = true
base.draggable.propagateEvents = false
base.draggable.constraints = base
base.draggable.overdrag = true

# pinch Start
base.on Events.PinchStart, (event, layer) ->
startPinch = event.scale

# pinch Start
base.on Events.Pinch, (event, layer) ->

# pinch End
base.on Events.PinchEnd, (event, layer) ->
base.animate
properties:
scale: 2
base.onAnimationEnd ->
base.draggable.constraints = base * 2

Stephen Etheredge

here's a basic version of what I am trying to do

Read the entire post on Facebook