@ue-too/animate / index / Animation
クラス: Animation<T>
定義: composite-animation.ts:740
Keyframe-based animation for a single value.
Remarks
The Animation class interpolates a value through a series of keyframes over time. It handles:
- Keyframe interpolation with binary search for efficiency
- Easing functions for smooth motion curves
- Reverse playback
- Looping with optional max loop count
- Delays before start and drag time after completion
- Lifecycle callbacks
How It Works
- Define keyframes at percentages (0.0 to 1.0) along the timeline
- Provide a callback to apply the animated value
- Provide an interpolation helper for the value type
- Call
animate(deltaTime)each frame to progress the animation
例
Animating a number with easing
let opacity = 0;
const fadeIn = new Animation(
[
{ percentage: 0, value: 0 },
{ percentage: 1, value: 1, easingFn: (t) => t * t } // Ease-in
],
(value) => { opacity = value; },
numberHelperFunctions,
1000 // 1 second duration
);
fadeIn.start();
// In animation loop
function loop(deltaTime: number) {
fadeIn.animate(deltaTime);
element.style.opacity = opacity;
}型パラメーター
T
T
The type of value being animated
実装
コンストラクター
コンストラクター
new Animation<
T>(keyFrames,applyAnimationValue,animatableAttributeHelper,duration,loop,parent,setUpFn,tearDownFn,easeFn):Animation<T>
定義: composite-animation.ts:766
パラメータ
keyFrames
Keyframe<T>[]
applyAnimationValue
(value) => void
animatableAttributeHelper
duration
number = 1000
loop
boolean = false
parent
AnimatorContainer | undefined
setUpFn
Function = ...
tearDownFn
Function = ...
easeFn
(percentage) => number
戻り値
Animation<T>
アクセッサー
delay
署名を取得する
get delay():
number
定義: composite-animation.ts:1102
戻り値
number
署名を設定する
set delay(
delayTime):void
定義: composite-animation.ts:1106
パラメータ
delayTime
number
戻り値
void
の実装
drag
署名を取得する
get drag():
number
定義: composite-animation.ts:1113
戻り値
number
署名を設定する
set drag(
dragTime):void
定義: composite-animation.ts:1117
パラメータ
dragTime
number
戻り値
void
の実装
duration
署名を取得する
get duration():
number
定義: composite-animation.ts:1054
戻り値
number
署名を設定する
set duration(
duration):void
定義: composite-animation.ts:1058
パラメータ
duration
number
戻り値
void
の実装
easeFunction
署名を取得する
get easeFunction(): (
percentage) =>number
定義: composite-animation.ts:1156
戻り値
(
percentage):number
パラメータ
percentage
number
戻り値
number
署名を設定する
set easeFunction(
easeFn):void
定義: composite-animation.ts:1160
パラメータ
easeFn
(percentage) => number
戻り値
void
keyFrames
署名を取得する
get keyFrames():
Keyframe<T>[]
定義: composite-animation.ts:1152
戻り値
Keyframe<T>[]
署名を設定する
set keyFrames(
keyFrames):void
定義: composite-animation.ts:1143
パラメータ
keyFrames
Keyframe<T>[]
戻り値
void
loops
署名を取得する
get loops():
boolean
定義: composite-animation.ts:1046
戻り値
boolean
署名を設定する
set loops(
loop):void
定義: composite-animation.ts:1050
パラメータ
loop
boolean
戻り値
void
の実装
maxLoopCount
署名を取得する
get maxLoopCount():
number|undefined
定義: composite-animation.ts:1196
戻り値
number | undefined
署名を設定する
set maxLoopCount(
maxLoopCount):void
定義: composite-animation.ts:1200
パラメータ
maxLoopCount
number | undefined
戻り値
void
の実装
playing
署名を取得する
get playing():
boolean
定義: composite-animation.ts:824
戻り値
boolean
の実装
trueDuration
署名を取得する
get trueDuration():
number
定義: composite-animation.ts:1124
戻り値
number
署名を設定する
set trueDuration(
duration):void
定義: composite-animation.ts:1128
パラメータ
duration
number
戻り値
void
メソッド
animate()
animate(
deltaTime):void
定義: composite-animation.ts:828
パラメータ
deltaTime
number
戻り値
void
の実装
clearOnEnd()
clearOnEnd():
void
定義: composite-animation.ts:1188
戻り値
void
の実装
clearOnStart()
clearOnStart():
void
定義: composite-animation.ts:1192
戻り値
void
の実装
detachParent()
detachParent():
void
定義: composite-animation.ts:1139
戻り値
void
の実装
findValue()
findValue(
valuePercentage,keyframes,animatableAttributeHelper):T
定義: composite-animation.ts:957
パラメータ
valuePercentage
number
keyframes
Keyframe<T>[]
animatableAttributeHelper
戻り値
T
nonCascadingDuration()
nonCascadingDuration(
newDuration):void
定義: composite-animation.ts:1075
パラメータ
newDuration
number
戻り値
void
の実装
onEnd()
onEnd(
callback):UnSubscribe
定義: composite-animation.ts:1164
パラメータ
callback
Function
戻り値
の実装
onStart()
onStart(
callback):UnSubscribe
定義: composite-animation.ts:1171
パラメータ
callback
Function
戻り値
の実装
onStartAfterDelay()
onStartAfterDelay(
callback):UnSubscribe
定義: composite-animation.ts:1180
パラメータ
callback
Function
戻り値
pause()
pause():
void
定義: composite-animation.ts:816
戻り値
void
の実装
resetAnimationState()
resetAnimationState():
void
定義: composite-animation.ts:1089
戻り値
void
の実装
resume()
resume():
void
定義: composite-animation.ts:820
戻り値
void
の実装
setParent()
setParent(
parent):void
定義: composite-animation.ts:1135
パラメータ
parent
戻り値
void
の実装
setUp()
setUp():
void
定義: composite-animation.ts:1037
戻り値
void
の実装
start()
start():
void
定義: composite-animation.ts:801
戻り値
void
の実装
stop()
stop():
void
定義: composite-animation.ts:809
戻り値
void
の実装
tearDown()
tearDown():
void
定義: composite-animation.ts:1042
戻り値
void
の実装
toggleReverse()
toggleReverse(
reverse):void
定義: composite-animation.ts:797
パラメータ
reverse
boolean
戻り値
void
の実装
wrapUp()
wrapUp():
void
定義: composite-animation.ts:1096
戻り値
void