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

What is Framer? Join the Community
Return to index
Jon Arnold
Posted Jun 21 - Read on Facebook

I want to add pressed states to my buttons:

# Touchtargets States Pressed
touchTargets = [btnOpenProfile,btnCloseModalWrapper]

for i in touchTargets
i.states.add
pressed:
opacity: 0.5
i.states.animationOptions = time: 0.01

i.on Events.Click, (event, id) ->
id.on Events.TouchStart, ->
id.states.switch "pressed"
id.on Events.TouchEnd, ->
id.states.switch "default"

Initially it doesn't work, but when I tap a button the next time it does :-(

Thoughts?

3 Comments

Arron J Hunt

Why have the Events.Click listener?

Trevor Phillippi

You're only adding those listeners when you click. Add the listeners right away. FWIW "Click" is triggered on mouse/touch up.

Jon Arnold

Yes, thank you!

Read the entire post on Facebook