Skip to content

@ue-too/animate / index / CompositeAnimation

類別: CompositeAnimation

定義於: composite-animation.ts:113

Container for sequencing and composing multiple animations.

備註

CompositeAnimation allows you to orchestrate complex animation sequences by:

  • Sequencing: Add animations to play one after another
  • Overlapping: Start animations before previous ones complete
  • Synchronizing: Play multiple animations simultaneously
  • Nesting: Compose animations contain other composite animations

Key Features

  • Add animations at specific time offsets
  • Position animations relative to other animations (addAnimationAfter, addAnimationBefore)
  • Automatic duration calculation based on child animations
  • Hierarchical composition for complex sequences
  • Prevent cyclic animation dependencies

範例

Basic sequence

typescript
const sequence = new CompositeAnimation();

// Add first animation at start (time 0)
sequence.addAnimation('fadeIn', fadeAnimation, 0);

// Add second animation after first completes
sequence.addAnimationAfter('slideIn', slideAnimation, 'fadeIn');

// Add third animation to overlap with second (100ms after second starts)
sequence.addAnimationAdmist('scaleUp', scaleAnimation, 'slideIn', 100);

sequence.start();

實作

建構函式

建構函式

new CompositeAnimation(animations, loop, parent, setupFn, tearDownFn): CompositeAnimation

定義於: composite-animation.ts:132

參數

animations

Map<string, { animator: Animator; startTime?: number; }> = ...

loop

boolean = false

parent

AnimatorContainer | undefined

setupFn

Function = ...

tearDownFn

Function = ...

回傳

CompositeAnimation

存取器

delay

Getter 簽章

get delay(): number

定義於: composite-animation.ts:540

回傳

number

Setter 簽章

set delay(delayTime): void

定義於: composite-animation.ts:533

參數
delayTime

number

回傳

void

實作了

Animator.delay


drag

Getter 簽章

get drag(): number

定義於: composite-animation.ts:551

回傳

number

Setter 簽章

set drag(dragTime): void

定義於: composite-animation.ts:544

參數
dragTime

number

回傳

void

實作了

Animator.drag


duration

Getter 簽章

get duration(): number

定義於: composite-animation.ts:338

回傳

number

Setter 簽章

set duration(duration): void

定義於: composite-animation.ts:342

參數
duration

number

回傳

void

實作了

Animator.duration


loops

Getter 簽章

get loops(): boolean

定義於: composite-animation.ts:590

回傳

boolean

Setter 簽章

set loops(loop): void

定義於: composite-animation.ts:594

參數
loop

boolean

回傳

void

實作了

Animator.loops


maxLoopCount

Getter 簽章

get maxLoopCount(): number | undefined

定義於: composite-animation.ts:683

回傳

number | undefined

Setter 簽章

set maxLoopCount(maxLoopCount): void

定義於: composite-animation.ts:687

參數
maxLoopCount

number | undefined

回傳

void

實作了

Animator.maxLoopCount


playing

Getter 簽章

get playing(): boolean

定義於: composite-animation.ts:679

回傳

boolean

實作了

Animator.playing

方法

addAnimation()

addAnimation(name, animation, startTime, endCallback): void

定義於: composite-animation.ts:414

參數

name

string

animation

Animator

startTime

number = 0

endCallback

Function = ...

回傳

void


addAnimationAdmist()

addAnimationAdmist(name, animation, admistName, delay): void

定義於: composite-animation.ts:467

參數

name

string

animation

Animator

admistName

string

delay

number

回傳

void


addAnimationAfter()

addAnimationAfter(name, animation, afterName, delay): void

定義於: composite-animation.ts:444

參數

name

string

animation

Animator

afterName

string

delay

number = 0

回傳

void


addAnimationBefore()

addAnimationBefore(name, animation, beforeName, aheadTime): void

定義於: composite-animation.ts:488

參數

name

string

animation

Animator

beforeName

string

aheadTime

number = 0

回傳

void


animate()

animate(deltaTime): void

定義於: composite-animation.ts:178

參數

deltaTime

number

回傳

void

實作了

Animator.animate


animateChildren()

animateChildren(deltaTime): void

定義於: composite-animation.ts:234

參數

deltaTime

number

回傳

void


calculateDuration()

calculateDuration(): void

定義於: composite-animation.ts:579

回傳

void


checkCyclicChildren()

checkCyclicChildren(): boolean

定義於: composite-animation.ts:598

回傳

boolean

實作了

AnimatorContainer.checkCyclicChildren


checkTerminalAndLoop()

checkTerminalAndLoop(): void

定義於: composite-animation.ts:201

回傳

void


childShouldAnimate()

childShouldAnimate(animation, prevLocalTime): boolean

定義於: composite-animation.ts:264

參數

animation
animator

Animator

startTime?

number

prevLocalTime

number

回傳

boolean


clearOnEnd()

clearOnEnd(): void

定義於: composite-animation.ts:671

回傳

void

實作了

Animator.clearOnEnd


clearOnStart()

clearOnStart(): void

定義於: composite-animation.ts:675

回傳

void

實作了

Animator.clearOnStart


containsAnimation()

containsAnimation(animationInInterest): boolean

定義於: composite-animation.ts:627

參數

animationInInterest

Animator

回傳

boolean

實作了

AnimatorContainer.containsAnimation


detachParent()

detachParent(): void

定義於: composite-animation.ts:174

回傳

void

實作了

Animator.detachParent


forceToggleLoop()

forceToggleLoop(loop): void

定義於: composite-animation.ts:620

參數

loop

boolean

回傳

void


getTrueDuration()

getTrueDuration(): number

定義於: composite-animation.ts:396

回傳

number


nonCascadingDuration()

nonCascadingDuration(newDuration): void

定義於: composite-animation.ts:367

參數

newDuration

number

回傳

void

實作了

Animator.nonCascadingDuration


onEnd()

onEnd(callback): UnSubscribe

定義於: composite-animation.ts:655

參數

callback

Function

回傳

UnSubscribe

實作了

Animator.onEnd


onStart()

onStart(callback): UnSubscribe

定義於: composite-animation.ts:662

參數

callback

Function

回傳

UnSubscribe

實作了

Animator.onStart


pause()

pause(): void

定義於: composite-animation.ts:305

回傳

void

實作了

Animator.pause


removeAnimation()

removeAnimation(name): void

定義於: composite-animation.ts:519

參數

name

string

回傳

void


removeDelay()

removeDelay(): void

定義於: composite-animation.ts:555

回傳

void


removeDrag()

removeDrag(): void

定義於: composite-animation.ts:562

回傳

void


resetAnimationState()

resetAnimationState(): void

定義於: composite-animation.ts:389

回傳

void

實作了

Animator.resetAnimationState


resume()

resume(): void

定義於: composite-animation.ts:312

回傳

void

實作了

Animator.resume


setParent()

setParent(parent): void

定義於: composite-animation.ts:170

參數

parent

AnimatorContainer

回傳

void

實作了

Animator.setParent


setUp()

setUp(): void

定義於: composite-animation.ts:400

回傳

void

實作了

Animator.setUp


start()

start(): void

定義於: composite-animation.ts:319

回傳

void

實作了

Animator.start


stop()

stop(): void

定義於: composite-animation.ts:328

回傳

void

實作了

Animator.stop


tearDown()

tearDown(): void

定義於: composite-animation.ts:407

回傳

void

實作了

Animator.tearDown


toggleReverse()

toggleReverse(reverse): void

定義於: composite-animation.ts:160

參數

reverse

boolean

回傳

void

實作了

Animator.toggleReverse


updateDuration()

updateDuration(): void

定義於: composite-animation.ts:569

回傳

void

實作了

AnimatorContainer.updateDuration


wrapUpAnimator()

wrapUpAnimator(animation, prevLocalTime): void

定義於: composite-animation.ts:281

參數

animation
animator

Animator

name

string

startTime?

number

prevLocalTime

number

回傳

void