Skip to content

Components API

Tween

The basic animation component for single tweens. Under the hood, Tween uses a GSAP timeline so it behaves consistently with nested timeline-based animations while still representing a single atomic animation.

Tween Props

PropTypeDefaultDescription
method'from' | 'to' | 'fromTo' | 'effect:%NAME%'-GSAP tween method
varsgsap.TweenVars | [gsap.TweenVars, gsap.TweenVars]-Animation variables
groupbooleanfalseAnimate children as group
tagstring'div'Wrapper element tag
progressnumber-Animation progress (0-1)
toggleboolean | undefined-Play/reverse control
parentAnimation | null-Parent animation
positiongsap.Position-Position in parent

Tween Events

EventDescription
startAnimation started
completeAnimation completed
updateAnimation updated
repeatAnimation repeated
reverseCompleteReverse animation completed
interruptAnimation interrupted

Tween Exposed

PropertyTypeDescription
animationAnimationAnimation instance
controlledComputedRef<boolean>Whether animation is controlled
parent{ parent: Animation | null }Parent animation info
progressComputedRef<number>Current animation progress (0-1)

Slot Props

The default slot receives the same exposed properties:

vue
<template>
  <Tween
    method="to"
    :vars="{ x: 100, duration: 1 }"
    v-slot="{ animation, controlled, progress }"
  >
    <div>Animated Element</div>
  </Tween>
</template>

Timeline

Component for creating complex animation sequences. Timeline can manage nested child animations and also compose multi-step animations from an array of definitions using the tweens prop.

Timeline Props

PropTypeDefaultDescription
tweensArray<TweenAnimationDefinition & { position?: gsap.Position }>-Array of tween definitions
durationnumber-Total timeline duration
optionsgsap.TimelineVars-GSAP timeline options
groupbooleanfalseAnimate children as group
tagstring'div'Wrapper element tag
progressnumber-Timeline progress (0-1)
toggleboolean | undefined-Play/reverse control
parentAnimation | null-Parent animation
positiongsap.Position-Position in parent

Timeline Events

Same as Tween component:

  • start, complete, update, repeat, reverseComplete, interrupt

Timeline Exposed

PropertyTypeDescription
animationAnimationAnimation instance
controlledComputedRef<boolean>Whether animation is controlled
parent{ parent: Animation | null }Parent animation info
progressComputedRef<number>Current timeline progress (0-1)

Usage Modes

The Timeline component can be used in two ways:

  1. With tweens prop - Define animations as an array:
vue
<Timeline :tweens>
  <div>Content</div>
</Timeline>
  1. With nested components - Manage nested animations via provide/inject:
vue
<Timeline>
  <Tween method="to" :vars="{ x: 100, duration: 1 }">
    <div>Child animation</div>
  </Tween>
</Timeline>

PositionMarker

Component for adding position markers (i.e. labels) to timelines.

PositionMarker Props

PropTypeDefaultDescription
labelstring-Marker label
parentAnimation | nullInjectedParent animation
positiongsap.Position-Marker position

PositionMarker Events

EventDescription
crossMarker crossed during playback

PositionMarker Usage

vue
<template>
  <Timeline>
    <PositionMarker label="start" />
    <Tween method="to" :vars="{ x: 100, duration: 1 }" />
    <PositionMarker label="middle" />
    <Tween method="to" :vars="{ y: 100, duration: 1 }" />
  </Timeline>
</template>

Note

The label prop of the PositionMarker component is read immediately upon component instantiation and is not reactive. Any changes to the prop value after instantiation will not trigger updates or re-registration of the marker.

Callback

Component for adding callbacks to timelines.

Callback Props

PropTypeDefaultDescription
fn(timeline: gsap.core.Timeline) => void-Callback function
parentAnimation | nullInjectedParent animation
positiongsap.Position-Callback position

Callback Usage

vue
<template>
  <Timeline>
    <Tween method="to" :vars="{ x: 100, duration: 1 }" />
    <Callback :fn="onComplete" position="+=0.5" />
  </Timeline>
</template>

<script setup>
const onComplete = (timeline) => {
  console.log('Animation complete!', timeline)
}
</script>