Settings
Configure the editor from your code with editor.config().
Import editor from the editor package and call editor.config() right after the import:
import { editor } from '@animatorkit/editor';
editor.config({
warnings: false,
defaultPlayback: { loop: true },
});
With the Vite plugin, this import also loads Editor Kit when it is installed. Without Vite, import it from '@animatorkit/editor-kit' with Editor Kit.
Parameters
| Name | Default | Accepts |
|---|---|---|
| save (opt) | true |
Boolean. false disables saving, for a public demo page with no save server |
| defaultLayout (opt) | null |
An Object. The layout the editor opens with |
| defaultPlayback (opt) | null |
An Object. The snap, speed and loop of the timeline when the page opens |
| onToggle (opt) | null |
A Function that receives false when the editor hides and true when it shows |
| three (opt) | null |
An Object with the camera and renderer of a Three.js scene. See Three.js scenes |
| warnings (opt) | true |
Boolean. false silences the editor warnings in the console |
| debounceTimer (opt) | 150 |
Number. The delay in milliseconds before the editor stores your unsaved edits in the browser tab |
save
With save: false, SAVE stays disabled with a "Save is disabled in this demo" note. Versions and undo keep working in the browser tab:
editor.config({ save: false });
defaultLayout
defaultLayout sets which parts of the editor show, and how, when the page opens. A visitor who changes the layout keeps that choice on every page of your site until the browser tab closes.
editor.config({
defaultLayout: {
menuExpanded: true,
settersOpen: false,
timelineHeight: 400,
},
});
| Name | Default | Accepts |
|---|---|---|
| editorVisible (opt) | true |
Boolean. false opens the page with the editor hidden |
| menuExpanded (opt) | false |
Boolean. Opens the expanded menu in place of the menu strip |
| menuItemOpen (opt) | '' |
'kinds' for the Objects list, 'save', 'settings' or 'status'. The menu panel that opens with the page |
| editorWindowVisible (opt) | false |
Boolean. Opens the editor window |
| editorWindowDock (opt) | 'right' |
'right' or 'viewportRight'. In docked mode, the editor window at the right edge or next to your website |
| timelineVisible (opt) | true |
Boolean. false closes the timeline |
| timelineMinimized (opt) | false |
Boolean. Shrinks the timeline to a strip |
| timelineSidebarVisible (opt) | true |
Boolean. false hides the timeline sidebar |
| timelineTransportOpen (opt) | false |
Boolean. Opens the playback settings of the timeline |
| timelineHeight (opt) | 300 |
Number. The height of the timeline in pixels, floating or docked |
| settersOpen (opt) | true |
Boolean. false closes the Setters folder of the Objects list |
| animationsOpen (opt) | true |
Boolean. false closes the Animations folder |
| timelinesOpen (opt) | true |
Boolean. false closes the Timelines folder |
| layoutsOpen (opt) | true |
Boolean. false closes the Layouts folder |
defaultPlayback
defaultPlayback sets the timeline controls when the page opens. A visitor who changes a control keeps that choice until the browser tab closes.
| Name | Default | Accepts |
|---|---|---|
| snap (opt) | true |
Boolean. Turns snap to grid on or off |
| speed (opt) | 'mid' |
'min' for slow motion, 'mid' for normal, 'max' for fast motion |
| loop (opt) | false |
Boolean. Turns the loop button on |
onToggle
Use onToggle to show your own button that brings the editor back with showEditor(). When the page opens with the editor hidden, the editor calls onToggle(false) at once:
// <button class="show-editor" hidden>Show editor</button>
const $button = document.querySelector('.show-editor');
$button.onclick = () => showEditor();
editor.config({ onToggle: visible => $button.hidden = visible });
editor.select()
editor.select(id) selects an object, or a child of a timeline, by its id, as a click on its row does. Call it after the code that creates the object, for example to open a demo page on one animation:
editor.select('Cards intro');