ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Penner easing expressions with layer slide

FAQ   •   VIEW ALL
 Penner easing expressions with layer slide on Dec 5, 2019 at 12:13:03 pm

Hi all

I'd like to find a way to slide a layer into position based on it's in point. Currently I am using this expression.

/* Legend:
t: current time
b: beginning value
c: change In value
d: duration
*/

function easeInOutExpo (t, b, c, d) {
t /= d/2;
if (t < 1) return c/2 * Math.pow( 2, 10 * (t - 1) ) + b;
t--;
return c/2 * ( -Math.pow( 2, -10 * t) + 2 ) + b;
};

var xstartVal = 500;
var ystartVal = 500
var xendVal = 500;
var yendVal = 800;
var startDur = 0;
var endDur = 1.8;

t = time - startDur;
d = endDur - startDur;

y = easeInOutExpo (t,ystartVal, yendVal - ystartVal, d);
x = easeInOutExpo (t,xstartVal, xendVal - xstartVal, d);

[x,y];

I'd like to be able to alter the ease velocity and looking a Robert Penner's site I have tried to insert the easeOutQuint function but it failed spectacularly.

This was Penner's easeOutQuint expression

public static float easeInOut (float t,float b , float c, float d) {
if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
return c/2*((t-=2)*t*t*t*t + 2) + b;
}

But it would be useful to be able to use any of his expressions.

Is there an easy way to do it?

 Return to posts index

 Re: Penner easing expressions with layer slideon Dec 5, 2019 at 8:00:27 pm

I think this works:

``` function easeInOut (t,b,c,d) { if (t <= 0) return b; if (t >= d) return b + c; if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; return c/2*((t-=2)*t*t*t*t + 2) + b; } var xstartVal = 500; var ystartVal = 500 var xendVal = 500; var yendVal = 800; var startDur = 0; var endDur = 1.8; t = time - startDur; d = endDur - startDur; y = easeInOut (t,ystartVal, yendVal - ystartVal, d); x = easeInOut (t,xstartVal, xendVal - xstartVal, d); [x,y]; ```

Dan

 Return to posts index

 Re: Penner easing expressions with layer slideon Dec 9, 2019 at 10:18:46 am

That works a treat, thanks so much Dan

 Return to posts index

 Re: Penner easing expressions with layer slideon Dec 9, 2019 at 11:15:00 am

Hey Dan

Just playing around with this one, is there a way to start the animation based on the layers inPoint?

Currently it starts animating at frame 0

Thanks

 Return to posts index

 Re: Penner easing expressions with layer slideon Dec 9, 2019 at 5:05:17 pm

I haven't tested it, but I think all you'd have to do is change this:

t = time - startDur;

to this:

t = time - (startDur + inPoint);

Dan

 Return to posts index

 Re: Penner easing expressions with layer slideon Dec 9, 2019 at 5:08:42 pm

Hey Dan

That works perfectly. Thanks so much.

Olly

 Return to posts index

© 2020 CreativeCOW.net All Rights Reserved
[TOP]