<p>Use the values of the keyframes as the driver for a <code>linear</code> expression, and scale them with the slider:</p>
<pre><code>const firstKF = thisProperty.key(1); //which KeyFrames to use as the driver
const lastKF = thisProperty.key(2); // NB you could use multiple keyframes with this expression
const initialValue = [960, 540]; // the start pos—could also use [thisComp.width, thisComp.height]/2
const offsetAmt = thisLayer.effect(&quot;offset slider&quot;)(&quot;Slider&quot;); //pickwhip the slider control here
const finalValue = initialValue + [offsetAmt, 0];

linear(value, firstKF, lastKF, initialValue, finalValue)
</code></pre>
<p>This will scale the original motion as you've keyframed it to match the motion with the offset applied.</p>

CC BY-SA 4.0
2022-07-03T10:02:19.620Z
2022-07-03T11:10:48.637Z
2022-07-03T11:10:48.637Z
stib
<p>In After Effects, I want to animate an object from a position A = (960, 540), being the center of my 1920x1080 composition, to a position B = (960 - offset, 540) to the left, where offset is a positive number. My composition will be used as Motion Graphics template, so this offset needs to be adjustable with a Slider Control so that users can tweak the amount of movement.</p>
<p>In <a href="https://video.stackexchange.com/questions/21055/control-key-frame-value-with-slider-control">this question</a>, a method is shown where a slider can be used to interpolate between two positions. However, I want to have the temporal interpolation to be predefined, and it is more complicated than the simple linear or ease interpolation that expressions allow for.</p>
<p>Thus, I want to be able to set the keyframe values with the slider, but I want the keyframe interpolation to be done with the graph editor. How can I make this work?</p>

<after-effects><after-effects-expressions>
After Effects set keyframe value with slider and expression but interpolation with graph editor
Wessel van Dam
# After Effects set keyframe value with slider and expression but interpolation with graph editor

(Asked by: username_0 on 2022-06-25)

In After Effects, I want to animate an object from a position A = (960, 540), being the center of my 1920x1080 composition, to a position B = (960 - offset, 540) to the left, where offset is a positive number. My composition will be used as Motion Graphics template, so this offset needs to be adjustable with a Slider Control so that users can tweak the amount of movement.

In [this question](https://video.stackexchange.com/questions/21055/control-key-frame-value-with-slider-control), a method is shown where a slider can be used to interpolate between two positions. However, I want to have the temporal interpolation to be predefined, and it is more complicated than the simple linear or ease interpolation that expressions allow for.

Thus, I want to be able to set the keyframe values with the slider, but I want the keyframe interpolation to be done with the graph editor. How can I make this work?

**Tags:** after-effects, after-effects-expressions


---

## 1 answers

### Answer by username_1 on 2022-07-03. Score: 0

Use the values of the keyframes as the driver for a linear expression, and scale them with the slider:
const firstKF = thisProperty.key(1); //which KeyFrames to use as the driver
const lastKF = thisProperty.key(2); // NB you could use multiple keyframes with this expression
const initialValue = [960, 540]; // the start pos—could also use [thisComp.width, thisComp.height]/2
const offsetAmt = thisLayer.effect("offset slider")("Slider"); //pickwhip the slider control here
const finalValue = initialValue + [offsetAmt, 0];

linear(value, firstKF, lastKF, initialValue, finalValue)

This will scale the original motion as you've keyframed it to match the motion with the offset applied.


---

