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

What is Framer? Join the Community
Return to index
Perre DiCarlo
Posted Apr 18 - Read on Facebook

Hi all, is there a Coffeescript equivalent to autoAlpha, which dynamically toggles visibility based on whenever opacity enters or exits 0?

To improve performance with lots of hidden objects, and to be confident that if I previously hid something, it won’t interfere with my currently visible objects, I frequently find myself adding lines of code around my opacity instructions that toggles the visibility of an object, or when animating opacity to 0, adding an event listener that follows opacity animation (see image).

autoAlpha does this in one step (and without an event listener). For example autoAlpha:1 first toggles visible to true, then animates the object to opacity 1. Conversely, autoAlpha:0 animates an object’s opacity to 0, then once finished, it automatically toggles visibility to false.

I first encountered autoAlpha in Greensock’s plugins for Javascript and before that ActionScript. Perhaps a combined opacity+visibility control exists in Coffeescript or other languages with a different name? Thanks!

4 Comments

George Kedenburg III

not sure if im following you completely but do you want a layer that automatically toggles it's visibility when the opacity reaches 0?

Sergey Voronov

Looking into this also. Problem is having transparent layers and events listeners on them. Of course booleans and ignoreevents is way to go, but seems like overkill

George Kedenburg III

this should be all you need

Perre DiCarlo

Thanks for this snippet George —excellent approach for one object at a time. I’m looking to (as Jordan and Sergey mention) create a snippet that applies to all layers (assuming a Coffeescript-native solution doesn’t already exist).

Read the entire post on Facebook