How mojs/mojs-timeline-editor works
1. This repository is a browser-based animation editor, not a server app. Its purpose is to provide a GUI for editing html, custom points, and timeline data while authoring mojs animations. The runtime boundary is the browser; there is no backend or API layer in this repo.
2. The app is a single-page frontend packaged into app/build/mojs-timeline-editor.js and bootstrapped from app/index.html. The codebase is built from Babel/JSX and PostCSS assets, with webpack and gulp handling bundling/watch workflows.
3. The core architectural style is React-style component composition plus centralized state. UI state is managed in Redux-like reducers under app/js/reducers, with a store defined in app/js/store.babel.js and at least one action module in app/js/actions. The reducers split the editor into distinct domains: controls, main panel layout, points, progress, and selected spot.
4. The main UI is decomposed into functional editor regions:
- main-panel for the central workspace,
- timeline-panel and timelines-panel for time-based editing,
- points-panel for point/property editing,
- tools-panel for editing modes and tool buttons.
This separation is important for drawing the architecture because each panel reads from shared state but owns a different part of the editing workflow.
5. The editor is data-driven around animation primitives such as points, segments, spots, and timelines. Helper constructors like create-point, create-segment, and create-spot indicate that the UI is built from structured domain objects rather than ad hoc component state. That suggests a clear flow from normalized domain data into rendered editor controls.
6. User interaction is heavily pointer-driven. Helpers such as add-pointer-down, add-pointer-up, change, and clamp imply custom drag/selection behavior for timeline handles, resize handles, and point editing. These low-level event helpers sit beneath the React components and feed state updates into reducers.
7. Persistence and selection are explicit concerns. Helpers like persist, is-selected-by-connection, and the selected-spot reducer indicate that selection state is tracked centrally and likely survives some form of editor refresh or session lifecycle. This is a key boundary between ephemeral UI gestures and persisted editor model state.
8. The components themselves are organized by feature, not by generic UI primitives. Examples include curve-editor, easing, point-line, segment-timeline, timeline-handle, and insert-point. These are the visual affordances used to manipulate timing curves, easing values, and point placement inside the timeline editor.
9. Styling is a first-class part of the architecture. The app/css/blocks and app/css/assets directories show a block-oriented CSS structure, with each component/region having its own PostCSS file and associated .json metadata. This suggests a component-to-style mapping that mirrors the UI decomposition.
10. There is a small utility/decorator layer under app/js/helpers/decorators for cross-cutting concerns such as refs, class names, and builder-style composition. This layer keeps the main components focused on editor behavior while standardizing repetitive wiring.
11. The external dependency that materially shapes the architecture is mojs. The README states the editor depends on mojs >= 0.225.2, with tween autoupdates available from 0.276.2. That means the editor is not a standalone animation engine; it is an authoring interface layered on top of mojs’ animation model.
12. Overall data flow is: pointer/UI events in the editor components -> helper functions and actions -> reducers update centralized editor state -> components re-render the panels, handles, points, and curves from that state. That loop is the core architecture to capture in a diagram.
13. The repository also includes mockup Sketch files and a coding guide, which are design/support artifacts rather than runtime dependencies. They reinforce that this project is an interaction-heavy editor where UI layout and manipulation behavior are central to the system.
Main entry points: timeline-editor.babel.jsx timeline editor · app.babel.jsx app root · timeline-panel.babel.jsx timeline panel · reducers reducers
Components 20
Browser runtime
Editor UI running in the browser
- index.html · Browser entry point that mounts the editor
app/index.html - editor bundle · Packaged frontend artifact delivered to the browser
app/build/mojs-timeline-editor.js
Editor UI
React-style component composition for the timeline editor
- app root · Top-level React application wiring
app/js/app.babel.jsx - timeline editor · Main editor shell coordinating panels
app/js/components/timeline-editor.babel.jsx - main panel · Central workspace for the editor surface
app/js/components/main-panel/main-panel.babel.jsx - timeline panel · Single-timeline editing surface
app/js/components/timeline-panel.babel.jsx - timelines panel · Multi-timeline overview and selection
app/js/components/timelines-panel.babel.jsx - points panel · Point and property editing surface
app/js/components/points-panel/points-panel.babel.jsx - tools panel · Editing modes and tool buttons
app/js/components/tools-panel/index.babel.jsx - curve editor · Easing and curve manipulation
app/js/components/curve-editor.babel.jsx
Central state
Redux-like state, actions, and reducers
Domain helpers
Animation model objects and interaction helpers
- create point · Constructs point domain objects
app/js/helpers/create-point.babel.js - create segment · Constructs segment domain objects
app/js/helpers/create-segment.babel.js - create spot · Constructs spot domain objects
app/js/helpers/create-spot.babel.jsx - pointer helpers · Custom pointer and change handling for drag/select behavior
app/js/helpers - selection/persist · Selection checks and persistence boundary
app/js/helpers/persist.babel.js
Build system
Bundling, transpilation, and stylesheet workflows
- style blocks · Block-oriented PostCSS styles mapped to UI regions
app/css/blocks - build tools · Webpack and gulp workflows for bundling and watch builds
webpack.config.js
Connections 22
- index.html → app root: bootstraps · HTML loads the application entry
- app root → timeline editor: renders · Top-level app composes the editor shell
- timeline editor → main panel: uses · Shell delegates the workspace region
- timeline editor → timeline panel: uses · Shell includes the main timeline editor
- timeline editor → timelines panel: uses · Shell includes timeline overview controls
- timeline editor → points panel: uses · Shell includes point and property editing
- timeline editor → tools panel: uses · Shell includes mode and tool controls
- timeline editor → curve editor: uses · Shell includes easing and curve editing
- app root → store: connects · App wires the component tree to centralized state
- store → reducers: uses · Store is composed from reducer slices
- actions → reducers: updates · Actions are reduced into editor state changes
- main panel → pointer helpers: handles · Workspace interactions depend on low-level pointer logic
- timeline panel → pointer helpers: handles · Timeline handles use drag and clamp behavior
- points panel → create point: builds · Point editing is driven by point domain objects
- timeline panel → create segment: builds · Timeline editing is driven by segment objects
- timelines panel → create spot: builds · Multi-timeline editing uses spot objects
- tools panel → actions: dispatches · Tool changes and mode toggles dispatch actions
- selection/persist → reducers: tracks · Selection state is centralized in reducers
- style blocks → timeline editor: styles · Block styles mirror editor regions
- build tools → editor bundle: packages · Toolchain produces the browser bundle
- build tools → style blocks: processes · Build pipeline handles stylesheet compilation
- editor bundle → timeline editor: contains · Built artifact contains the editor application