Skip to content

Commit 414f06b

Browse files
author
John Colombo
committed
Add previousKey and nextKey to Property
1 parent 4a8894b commit 414f06b

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

‎docs/objects/property.md‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,69 @@ twoSecondKey.value;
336336

337337
---
338338

339+
### nextKey()
340+
341+
`thisLayer.position.nextKey(time)`
342+
343+
!!! note
344+
This functionality was added in After Effects (Beta) 26.0 and is subject to change while it remains in Beta.
345+
346+
#### Description
347+
348+
Returns the keyframe or marker after the specified time. If the specified time is after the last keyframe or marker, returns the last keyframe or marker.
349+
350+
This method is available only in expressions using the JavaScript expression engine.
351+
352+
#### Parameters
353+
354+
| Parameter | Type | Description |
355+
| --------- | ------ | ------------------------------------------------- |
356+
| `time` | Number | The time, in seconds, to find the next key from |
357+
358+
#### Returns
359+
360+
Key or MarkerKey
361+
362+
---
363+
364+
### previousKey()
365+
366+
`thisLayer.position.previousKey(time)`
367+
368+
!!! note
369+
This functionality was added in After Effects (Beta) 26.0 and is subject to change while it remains in Beta.
370+
371+
#### Description
372+
373+
Returns the keyframe or marker at or before the specified time. If none exist before the specified time, returns the first keyframe or marker.
374+
375+
This method is available only in expressions using the JavaScript expression engine.
376+
377+
#### Parameters
378+
379+
| Parameter | Type | Description |
380+
| --------- | ------ | ------------------------------------------------------ |
381+
| `time` | Number | The time, in seconds, to find the previous key from |
382+
383+
#### Returns
384+
385+
Key or MarkerKey
386+
387+
#### Example
388+
389+
**Trigger property's keyframes at each layer marker:**
390+
391+
```js
392+
const animDuration = key(numKeys).time - key(1).time;
393+
const animTime = time - marker.previousKey(time).time;
394+
395+
const animRemap = linear(animTime, 0, animDuration, key(1).time, key(numKeys).time);
396+
397+
valueAtTime(animRemap);
398+
```
399+
400+
---
401+
339402
### propertyGroup()
340403

341404
`thisLayer.position.propertyGroup([countUp=1])`

0 commit comments

Comments
 (0)