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

What is Framer? Join the Community
Return to index
Tebza Ngwana
Posted Apr 12 - Read on Facebook

Sup fellow framers

i've encountered a problem i was hoping yol could help me out. i've got a function that creates a progress bar, now i want to attach this function only to a certain layer. any ideas how i can accomplish this?

13 Comments

Chris Camargo

I think we'd need to see the function first.

Tebza Ngwana

Here it is.

Tebza Ngwana

proBar = ->

radius = 90
num = 0

circle = new Layer
borderRadius: 100
width: 11
height: 11
backgroundColor: '#00AEEF'
x: Screen.width / 2 + radius * Math.cos(num) + (-8.5)
y: Screen.height / 2 + radius * Math.sin(num) - 371.5

#BLUE PROGRESS
Utils.interval 0, ->
if num < Math.PI * 2
num = num + 0.04
circle.x = Screen.width / 2 + radius * Math.cos(num) + (-8.5)
circle.y = Screen.height / 2 + radius * Math.sin(num) - 371.5
copy = circle.copy()

#WHITE PROGRESS
Utils.interval 0.4, ->
if num > Math.PI * 2
if num isnt 12.599999999999907
circle.backgroundColor = "#FFFFFF"
circle.width = 11
circle.height = 11
num = num + 0.04
circle.x = Screen.width / 2 + radius * Math.cos(num) + (-8.5)
circle.y = Screen.height / 2 + radius * Math.sin(num) - 371.5
copy = circle.copy()

Tebza Ngwana

Chris Camargo How do you think i can pull this off buddy?

Tebza Ngwana

Marc Krenn any ideas bro?

Tes Mat

Tebza Ngwana You’ll have to add an argument to your function: the layer it should be placed in. Like this: http://share.framerjs.com/ybtr01ygczgx/ (I removed all those calculations that use the screen size for positioning, because you’ll have to change them to using the parent layer)

Tes Mat

Tebza Ngwana But, actually, you would be better of animating an SVG instead of creating all these overlapping layers…

Tes Mat

For a start: check out Josh Puckett’s SVG module: https://www.facebook.com/groups/framerjs/permalink/757715437688863/

Tebza Ngwana

Thanks Tes Mat

Tebza Ngwana

Thanks a lot Jordan Robert Dobson

Jordan Robert Dobson

No problem... I have a lot of work to post up to http://FramerCo.de

Read the entire post on Facebook