@nextgensoftwares/folio-slides-motion
Slide animations and transitions, DOM-free: it plays the PowerPoint timing model (Slide.timing, see folio-slides) the way PowerPoint does, computes transitions and morph, and runs a slide show. Renderers ask it, for any shape, paragraph, word or letter at any moment, for a MotionState (visibility, opacity, offset, scale, rotation, shear, reveal clip, colour tweens) and draw it. React UI: folio-plugin-slides-motion. Guide: Slide animations.
ts
import { ShowController } from '@nextgensoftwares/folio-slides-motion';
const show = new ShowController(presentation);
show.next(); // a click: the next build, else the next slide
const { index, motion, transition } = show.frame();
motion.of('5'); // { visible, opacity, dx, dy, sx, sy, rot, reveal?, fill? } or null
motion.of('5', { para: 1, element: { index: 3, count: 20 } });Playback
| Export | Description |
|---|---|
compileTimeline(slide, options), Timeline, TimelineOptions, TargetBox, Instance, Sequence | a slide's timing compiled for playback: the main sequence and triggers with their steps, every behaviour indexed by shape; options { size, box(id), color?(ref) } |
evaluate(timeline, play, now), Frame, PlayState | a moment: play holds the start time of every started step ({ main, triggers? }); frame.of(shape, part?) gives the MotionState or null (not animated) |
Part, matches(target, part) | { para?, bg?, element?: { index, count }, box? }: what a query is about |
iterationOf(tl, shape, para), animatesParts(tl, shape), animatedShapes(tl) | by-word / by-letter builds and where they count from; whether a shape's text animates on its own |
MotionState, IDENTITY, identity(), isIdentity(s), compose(outer, inner) | the state renderers apply (paragraph states compose with their shape's) |
ColorTween, mixColor(base, tween), Reveal | a colour animation (to/from/by, RGB or HSL), a reveal filter in progress |
revealClip(reveal, w, h), parseFilter(filter), Clip | the visible region of animEffect filters (wipe, barn/split, blinds, box, checkerboard, circle, diamond, dissolve, plus, random bars, slide, strips, wedge, wheel) as polygons |
nodeTime(node, local), NodeTime, easeAccelDecel(t, a, d), applyTmFilter(spec, p) | SMIL time: repeats, rewind, speed, acceleration/deceleration, tmFilter |
compileFormula(src), evalFormula(src, vars), FormulaVars | #ppt_x+.1, 1+#ppt_h/2, sin(2*pi*$)... |
parsePath(d, aspect?), pointAt(path, p), linePath(points), MotionPath | motion paths (M/L/C/Z/E, slide fractions), constant speed by arc length |
slideBoxes(pres, index) | every shape's box in slide px (placeholders resolved, group children mapped) |
Transitions and morph
| Export | Description |
|---|---|
transitionFrame(transition, p, W, H), TransitionFrame, TransitionLayer | the outgoing and incoming slides at progress p: opacity, offset, scale, rotation, clip, order, a colour through (fade through black) |
transitionDuration(t), transitionSupport(type), TRANSITIONS | length in ms (cut/none: 0); 'exact' or 'approx' (played as a fade) |
morphPlan(from, to), morphFrame(plan, fromBoxes, toBoxes, p), MorphPair, MorphShape | shapes matched across slides (!!name, same id, same name, same text) and their interpolated boxes and cross-fade |
Slide show
| Export | Description |
|---|---|
ShowController(pres, options?, start?), ShowOptions | next(), prev(), goTo(index, { built?, transition? }), click(shape) (triggers), setBlank('black' | 'white' | null), tick() (slide timings), frame(now?), snapshot / restore(snap, force?) (window sync), on(fn), order, stepsLeft, rehearsal (ms per slide), timeline(i), boxes(i), setPresentation(p). Options: now, color(index), reducedMotion, includeHidden, follower |
ShowSnapshot, ShowFrame | plain-JSON state (index, slideStart, from, steps, triggers, blank, ended, seq); what to draw now |
ShowController.cues(from, to), cuesBetween(tl, snap, transition, from, to), ShowCue, CueAction, TimelineCue, CueSource | the sounds and media commands due in (from, to]: the transition sound when the slide came in with its transition, then each started step's { kind: 'sound', src, loop? }, { kind: 'stopSounds' }, { kind: 'media', shape, verb, from? }. Steps finished early start in the past, so skipped cues never play |
effectCues(effect, seq, step, at), mediaVerb(cmd), MediaVerb | an effect's cues; p:cmd to play (with from for playFrom(s)), pause, resume, stop, toggle |
busyUntil(show) | when the current slide stops moving (renderers idle after it) |
InkStroke, InkLayer, INK_TOOLS, eraseAt(strokes, x, y, r) | pen / highlighter strokes in slide px, per slide |
Presets
| Export | Description |
|---|---|
ENTRANCE, EMPHASIS, EXIT, PATHS, PRESETS, Preset, PresetOption | the gallery: PowerPoint preset ids and classes, directions (presetSubtype), the behaviours PowerPoint writes for each |
presetByKey(key), presetOf(effect), effectLabel(effect) | lookup; the pane label ("Fly in", "Custom path", "Entrance 37") |
createEffect(preset, options), EffectOptions, customPath(options, points), changePreset(effect, preset, subtype?), asExit(behaviors, dur) | new effects; a different preset keeping timing |
effectDurationOf(e), setEffectDuration(e, ms) | one pass of an effect; rescale its behaviours |
Editor commands (/editor)
motionPlugin() is a SlidesPlugin for folio-slides-editor (animationCommands, inkCommands):
| Command | Args |
|---|---|
animation.add | AddAnimationArgs { preset, subtype?, shapes?, start?, byParagraph?, points?, ids? } (default: the selection; text shapes get a build group) |
animation.remove, animation.change | { ids }; { ids, preset, subtype? } |
animation.timing | { ids, start?, delay?, duration?, repeat?, rewind? } |
animation.iterate, animation.move, animation.trigger | { ids, iterate } (by word / letter); { ids, to }; { ids, shape | null } |
transition.apply | { type?, options?, duration?, advanceAfter?, advanceOnClick?, all? } |
show.applyTimings, show.keepInk | { times } (rehearsed); { ink } (strokes become freeform shapes) |
Helpers: paneRows(timing) (PaneRow: rows of the animation pane, by-paragraph groups together, click numbers), allEffects, mapEffects, tidy, nextGroup, buildFor, textParagraphs, timingOf, effectId.
Recording
| Export | Description |
|---|---|
ShowTrack, TrackEvent, TrackEventKind, TrackShow | a recorded show: { format: 'folio-show-track', version: 1, durationMs, size, events }; events { t, k, ... } with t in ms from the recording's start (pauses cut out) and positions 0..1 of the slide: show (slide, builds, triggers, blank), nav.slide, pointer / pointer.hide, ink.start / ink.point / ink.end / ink.remove / ink.clear, text, text.box, typing, zoom, spotlight, media, overlay, marker |
ShowRecorder(show, options?), ShowRecorderOptions, RecorderState | records a ShowController plus what its UI reports: start, pause, resume, stop() → ShowTrack, time(), toTrack(wall), on(fn) (live events), onState(fn); pointer(at, laser?) (~30 Hz, the last sample always lands), inkStart / inkPoint / inkEnd / inkRemove / inkClear, text, textBox, typing, zoom, spotlight, media, overlay, marker (slide px) |
TrackPlayer(track, size?), TrackState | at(t): the state at a track time (show snapshot on the track's clock, ink, the pointer gliding between samples, zoom, spotlight, live text, typing, overlays); between(from, to) |
applyLiveText(deck, live), LiveText | the deck with text typed live into shapes and the text boxes added during the show |