1
1
/**
2
2
* @name Make Hold Keyframes
3
- * @version 1.3
3
+ * @version 1.4
4
4
* @author Kyle Martinez <www.kyle-martinez.com>
5
5
*
6
6
* @description Convert selected keyframes into hold keyframes.
13
13
* "A rising tide lifts all boats." - John F. Kennedy, 1963
14
14
*/
15
15
16
- ( function ( ) {
17
- function makeHoldKeyframe ( property , key ) {
18
- var hold = KeyframeInterpolationType . HOLD ;
19
- property . setInterpolationTypeAtKey ( key , hold , hold ) ;
20
- }
16
+ ( function makeHoldKeyframes ( ) {
17
+ var HOLD = KeyframeInterpolationType . HOLD ;
21
18
22
- function findSelectedKeyframes ( property ) {
19
+ function setKeyframesToHold ( property ) {
23
20
var keys = property . selectedKeys ;
24
21
var numKeys = keys . length ;
25
22
for ( var k = 0 ; k < numKeys ; k ++ ) {
26
- var key = keys [ k ] ;
27
- makeHoldKeyframe ( property , key ) ;
23
+ var index = keys [ k ] ;
24
+ property . setInterpolationTypeAtKey ( index , HOLD , HOLD ) ;
28
25
}
29
26
}
30
27
31
- function findSelectedProperties ( comp ) {
32
- var properties = comp . selectedProperties ;
33
- var numProperties = properties . length ;
34
- for ( var p = 0 ; p < numProperties ; p ++ ) {
35
- var property = properties [ p ] ;
36
- if ( property . canVaryOverTime === true ) {
37
- findSelectedKeyframes ( property ) ;
28
+ app . beginUndoGroup ( "Make Hold Keyframe(s)" ) ;
29
+ var comp = app . project . activeItem ;
30
+ var properties = comp . selectedProperties ;
31
+ var numProperties = properties . length ;
32
+ for ( var p = 0 ; p < numProperties ; p ++ ) {
33
+ var property = properties [ p ] ;
34
+ if ( property . propertyType === PropertyType . PROPERTY ) {
35
+ if ( property . isTimeVarying === true ) {
36
+ setKeyframesToHold ( property ) ;
38
37
}
39
38
}
40
39
}
41
-
42
- app . beginUndoGroup ( "Make Hold Keyframes" ) ;
43
- var comp = app . project . activeItem ;
44
- if ( comp !== null && ( comp instanceof CompItem ) ) {
45
- findSelectedProperties ( comp ) ;
46
- }
47
40
app . endUndoGroup ( ) ;
48
41
} ) ( ) ;
0 commit comments