Skip to main content
This example demonstrates the simplest way to get started with Helios using standard CSS animations. No framework required - just vanilla JavaScript, HTML, and CSS.

Overview

The basic animation example shows how to:
  • Initialize the Helios engine
  • Use CSS keyframes for animations
  • Sync animations with the document timeline
  • Create a composition ready for rendering

Setup

1

Create the HTML structure

Start with a basic HTML file containing an element to animate:
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Simple Composition</title>
</head>
<body>
  <div class="animated-box"></div>
  
  <script type="module" src="./src/main.ts"></script>
</body>
</html>
2

Add CSS animations

Define your animation using standard CSS keyframes:
body {
  margin: 0;
  overflow: hidden;
  background-color: #eee;
}

.animated-box {
  width: 150px;
  height: 150px;
  background-color: #007bff;
  position: absolute;
  top: 50%;
  left: 50%;
  /* Initial state */
  transform: translate(-50%, -50%) scale(0.5);
  opacity: 0;

  /* Use standard CSS animation */
  animation: moveAndScale 5s linear forwards;
}

@keyframes moveAndScale {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: translate(calc(-50% + 50vw - 100%), -50%) scale(1);
  }
}
3

Initialize Helios

Set up the Helios engine with autoSyncAnimations enabled to automatically control CSS animations:
import { Helios } from '@helios-project/core';
import './style.css';

// Initialize Helios engine
const helios = new Helios({
  duration: 5,
  fps: 30,
  autoSyncAnimations: true
});

// Expose for the Player and debugging
(window as any).helios = helios;

// Enable external control (e.g. from Renderer)
helios.bindToDocumentTimeline();

How it works

Auto sync animations

By setting autoSyncAnimations: true, Helios automatically hijacks all CSS animations on the page and synchronizes them with the video timeline. This means:
  • CSS animations pause, play, and seek in sync with the video
  • Frame-perfect rendering is guaranteed
  • No manual animation control needed

Document timeline binding

The bindToDocumentTimeline() method connects Helios to the browser’s document timeline, allowing external tools like the Helios Renderer to drive the animation playback.

Key concepts

  • Duration: Total length of your composition in seconds
  • FPS: Frames per second for rendering (typically 30 or 60)
  • autoSyncAnimations: Automatically sync CSS animations with Helios timeline
  • bindToDocumentTimeline: Enable external control for rendering

Complete example

View the complete source code in the simple-animation directory.

Next steps

Build docs developers (and LLMs) love