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

What is Framer? Join the Community
Return to index
Callum Nowlan-Dias
Posted Oct 06 - Read on Facebook

I want to decrease a counter by 1 every time listIcon is clicked, but the decrease is only firing once.

counterValue = 3
counter.templateFormatter = (value) ->

template: counterValue

listIcon.onClick ->
print "trigger"
template: counterValue - 1

How can I get this to fire until the counter is 0, where it stops?


Aalok Trivedi
Kevin Mao

The problem you have is that clicking listIcon animates the counter to a number equal to whatever counterValue is minus 1. This will always be 2, because you never set the value of counterValue to that new value-minus-one.

The solution is to decrement the counterValue and then animate to it. Then put it all under a conditional that won't do anything if counterValue reaches 0.

Callum Nowlan-Dias

thanks for the replies and the explanation, makes a lot of sense now

Read the entire post on Facebook