ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Opacity Rollover Expression Based on Null Proximity

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Dan Fassnacht
Opacity Rollover Expression Based on Null Proximity
on Feb 10, 2017 at 6:55:45 pm

Hey All,

Basically I'm trying to have a mouse rollover an icon and have it trigger the opacity of a highlight, similar to a rollover on a website. The opacity doesn't need to ease up or anything, just on and off. I'm just trying to find a better way to do this than manually.

Thanks any info!

Dan


Return to posts index

Dan Ebberts
Re: Opacity Rollover Expression Based on Null Proximity
on Feb 10, 2017 at 7:42:44 pm

In its simplest form, probably something like this:

dTrigger = 100; // trigger within 100 px
d = length(thisComp.layer("mouse").position,position);
d < dTrigger ? 100 : 0



Dan



Return to posts index

Dan Fassnacht
Re: Opacity Rollover Expression Based on Null Proximity
on Feb 10, 2017 at 8:58:04 pm

Thanks Dan, that's perfect.

Is there any version of this that would move the position of a layer if it's rolled over. So lets say I roll over an image with the mouse and it pushes the image down etc.

Thanks!

Dan


Return to posts index


Dan Ebberts
Re: Opacity Rollover Expression Based on Null Proximity
on Feb 10, 2017 at 9:12:16 pm

You could add a Transform effect to your layer and add something like this to the effect's Position property:

dTrigger = 100; // trigger within 100 px
d = length(thisComp.layer("mouse").position,position);
y = d < dTrigger ? 100 : 0;
value + [0,y]


Dan



Return to posts index

Dan Fassnacht
Re: Opacity Rollover Expression Based on Null Proximity
on Feb 10, 2017 at 10:34:34 pm

Great thanks Dan.

I had one more question, is there any way to Ease the movement/opacity so it's not on/off.

Thanks again, this is going to save me alot of time.


Return to posts index

Dan Ebberts
Re: Opacity Rollover Expression Based on Null Proximity
on Feb 10, 2017 at 10:48:50 pm

Like this maybe:

// Opacity

dMax = 100;
dMin = 0;
d = length(thisComp.layer("mouse").position,position);
ease(d,dMin,dMax,100,0)


// Transform effect/Position

dMax = 100;
dMin = 0;
yOffset = 100;
d = length(thisComp.layer("mouse").position,position);
y = ease(d,dMin,dMax,yOffset,0);
value + [0,y]


Dan



Return to posts index


Dan Fassnacht
Re: Opacity Rollover Expression Based on Null Proximity
on Feb 10, 2017 at 11:04:17 pm

Great! Thanks for taking the time Dan, much appreciated.

Best,

Dan


Return to posts index

Dan Fassnacht
Re: Opacity Rollover Expression Based on Null Proximity
on Feb 18, 2017 at 9:13:10 pm

Hi Dan,

I had one more question on this.

Is there anyway to have the trigger expression, trigger something that isn't necessarily square?

So basically I'm rolling over images that are rectangular that have different pixel proximities depending if I come from the side or top of the rectangle with the mouse cursor.

Thanks for any info!

- Dan


Return to posts index

Dan Ebberts
Re: Opacity Rollover Expression Based on Null Proximity
on Feb 18, 2017 at 9:23:03 pm

I think that's a much more complex expression. The target layer expression would have to calculate its own bounding box in the comp, figure out which edge the cursor is closest to, and calculate the distance based on that. Do-able but challenging. If I wasn't right in the middle of a project, I'd take a crack at it. Maybe somebody else will jump in.

Dan



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]