Components Media and time

KeyframeLane

Keyframes on a time lane: select, drag, and their interpolation shapes.

import { KeyframeLane } from '@kition/tessera-ui'

Keyboard

KeysWhat they do
Left, RightMove the selected keyframes by one frame.
EscapeWhile dragging: put the keyframes back where they were.

Examples

Three keyframes
keyframe-lane.tsx
import { useState } from 'react'
import { KeyframeLane, type Keyframe } from '@kition/tessera-ui'

export default function Demo() {
  const [keyframes, setKeyframes] = useState<Keyframe[]>([
    { id: 'a', time: 1 },
    { id: 'b', time: 3.5, interpolation: 'bezier' },
    { id: 'c', time: 6, interpolation: 'hold' },
  ])
  return (
    <div style={{ width: 360 }}>
      <KeyframeLane
        keyframes={keyframes}
        start={0}
        end={8}
        onSelect={(ids) => setKeyframes((list) => list.map((key) => ({ ...key, selected: ids.includes(key.id) })))}
        onMove={(ids, delta) => setKeyframes((list) => list.map((key) => (ids.includes(key.id) ? { ...key, time: Math.max(0, key.time + delta) } : key)))}
      />
    </div>
  )
}

Props

KeyframeLane

PropTypeDefaultDescription
keyframesrequiredreadonly Keyframe[]—
startrequirednumber—Visible range in seconds and the lane's width map times to x.
endrequirednumber—
onSelectrequired(ids: string[], add: boolean) => void—
onMoverequired(ids: string[], delta: number) => void—Called once on release with the dragged ids and the time delta.
snap(time: number) => number—
fpsnumber30Frames per second: an arrow key moves the selected keyframes one frame (30 by default).
onMenu(id: string, at: ContextMenuPoint) => void—A keyframe's menu was asked for at a screen point (upstream's interpolation menu).
uiIdstring—The Kit UI id every keyframe carries (control:effects.keyframe).
testIdstring—

Used in

1 of Kition's 16 kits use this component.

  • Film