Skip to content

Commit c8e1447

Browse files
committed
fix: property value used before construction
move value dependant properties to the constructor function
1 parent b7a9859 commit c8e1447

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/index.ts

+15-9
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,23 @@ export type Value =
219219

220220
export class Property<PropertyValueType extends Value> {
221221

222+
/**
223+
* The temporal velocity value at the current time. For spatial properties, such as Position, it returns the tangent vector value. The result is the same dimension as the property.
224+
*/
225+
readonly velocity: PropertyValueType;
226+
227+
/**
228+
* A 1D, positive speed value equal to the speed at which the property is changing at the default time. This element can be used only for spatial properties.
229+
*/
230+
readonly speed: PropertyValueType;
231+
222232
constructor(
223233
readonly value: PropertyValueType,
224234
readonly name: string = "Property name"
225-
) {}
235+
) {
236+
this.velocity = this.value;
237+
this.speed = this.value;
238+
}
226239

227240
/**
228241
* The number of keyframes on the property
@@ -314,21 +327,14 @@ export class Property<PropertyValueType extends Value> {
314327
): PropertyValueType {
315328
return this.value;
316329
}
317-
/**
318-
* The temporal velocity value at the current time. For spatial properties, such as Position, it returns the tangent vector value. The result is the same dimension as the property.
319-
*/
320-
readonly velocity: PropertyValueType = this.value;
330+
321331
/**
322332
* @returns The temporal velocity value at the specified time. For spatial properties, such as Position, it returns the tangent vector value. The result is the same dimension as the property.
323333
* @param time The composition time in seconds to get the velocity at
324334
*/
325335
velocityAtTime(time: number): PropertyValueType {
326336
return this.velocity;
327337
}
328-
/**
329-
* A 1D, positive speed value equal to the speed at which the property is changing at the default time. This element can be used only for spatial properties.
330-
*/
331-
readonly speed: PropertyValueType = this.value;
332338
/**
333339
* @returns A 1D, positive speed value equal to the speed at which the property is changing at the specified time. This element can be used only for spatial properties.
334340
* @param time The composition time in seconds to get the speed at

0 commit comments

Comments
 (0)