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

What is Framer? Join the Community
Return to index
Fran Pérez
Posted Nov 27 - Read on Facebook

I'm currently using Utils.mapRange, but I can't find it in the documentation. Is it deprecated or something?

14 Comments

John Anthony Evans

It's called Utils.modulate now I think

Fran Pérez

Mmmm according to the documentation it doesn't look to do the same :/

John Anthony Evans

Well mapRange is still in the source so you can always use that but they are basically the same in terms of intent.

Fran Pérez

The outcome is not the same… I'm using it to change some properties of a layer when dragging another layer. With modulate it doesn't work at all.

John Anthony Evans

Email me the framer and I'll take a look?

Fran Pérez

Check this out:

layerA = new Layer({width: 300,height: 300})
layerB = new Layer({x: 300, width: 300, height: 300})
layerA.draggable.speedX = 0
layerA.on Events.DragMove, -> layerB.x = Utils.mapRange(layerA.y, 0, 300, 300, 600)

John Anthony Evans

layerA = new Layer({width: 300,height: 300, background: utils.randomColor(0.5)})
layerB = new Layer({x: 300, width: 300, height: 300, background: utils.randomColor(0.3)})
layerA.draggable.speedX = 0
layerA.on Events.DragMove, -> layerB.x = Utils.modulate(layerA.y, [0, 300], [300, 600])

Fran Pérez

Ha OK! :)

Thanks

John Anthony Evans

BTW, not sure what you are doing but I've found listening to the change in a property better than using the drag event for mapping one thing to another

John Anthony Evans

So that last line would read:

layerA.on "change:y", -> layerB.x = Utils.modulate(layerA.y, [0, 300], [300, 600])

Fran Pérez

Oh, I didn't know that one. Thanks :)

Peter Ng

wth is change:y ?!?! there's such a thing?

Ed Chao

haha Peter

Koen Bok

Peter you can listen to any property change with "change:<property>"

Read the entire post on Facebook