Skip to content

Motion regions ​

These experimental additions require Jolt 0.1.0-rc.7 or later. They are included in Mavis 0.1.0-alpha.5.

MBox :motionRegion declares a stable region. Its descendant MCard and MButton surfaces borrow one Jolt context on Web. Each component retains its press layer; application interactions have their own cleanup. No DOM element, native View, selector or frame loop belongs in the shared recipe.

Built-in Vue components compare the keys of a layout region in their rendered order. Replacing an array with new records that have the same keys leaves the children in place, including when an item label changes. Insertion, removal and reordering can animate. Components with explicit geometry inputs, such as a responsive grid or a scheduler, also react when those positions change.

vue
<script setup lang="ts">
import { markRaw, onBeforeUnmount, ref } from 'vue'
import {
  createMotionRegion,
  createMotionSurface,
  whenMotionAvailable,
} from '@getcortexlabs/mavis-core/experimental'

const hoverAvailable = ref(false)
const region = markRaw(createMotionRegion())
const card = markRaw(createMotionSurface())
const remove = whenMotionAvailable([region, card], () =>
  card.use((motion) => {
    const pointer = motion.pointerFollow(region, {
      range: { x: [-12, 12], y: [-8, 8] },
      onAvailabilityChange: (available) => {
        hoverAvailable.value = available
      },
    })
    motion.bind({
      x: pointer.x,
      y: pointer.y,
      rotate: pointer.presence.to([0, 1], [0, -1.2]),
    })
  }),
)
onBeforeUnmount(remove)
</script>

<template>
  <m-box :motionRegion="region" padding="lg">
    <m-card :motionSurface="card" interactive accessibilityLabel="Open edition">
      <m-text>A new perspective.</m-text>
      <m-text v-if="hoverAvailable">↗</m-text>
    </m-card>
  </m-box>
</template>

Declare the region when mounting its Box. Keep the input wrapper separate from the animated target and leave room for its movement. Nested declared regions establish separate contexts: a shared identity or viewport group belongs to one region.

Interaction ownership ​

surface.use(setup) supplies a child surface. Create both initial work and later event-driven work through that child. Removing the subscription disposes its values, mappings, bindings and controllers while sibling owners and component press continue. A parent value passed to a child's binding is borrowed; removing the child does not dispose that value. Setup is synchronous and rolls back if it fails.

Mount/load creates a presentation. Ref replacement, KeepAlive deactivation and native unload destroy it; activation/load creates a fresh one. Old child handles cannot write to the new presentation. Keep durable application state outside setup and reapply it when the surface becomes available. Native Jolt scopes also recreate their subscriptions after app suspension. onAvailable remains supported; use is the explicit lifetime for interactions that create work after setup returns.

Bounded pointer input ​

pointerFollow returns x, y and presence, with available, active and execution. Both renderers delegate hover, geometry, bounds, springs, suspension and live reduced motion to Jolt: its Web runtime in the browser and its native pointer input on NativeScript. Touch and pen contact are not hover, so scrolling, taps and focus stay with the app.

  • x and y follow the pointer inside your range. With coordinates: 'pixels' they are measured from the region's centre: viewport CSS pixels on the Web, the region's local DIPs on NativeScript.
  • presence is 1 while a hovering pointer is inside the region and 0 otherwise: outside, disabled, suspended, and wherever hover does not exist. Map it like any other value, for example pointer.presence.to([0, 1], [0, -1.2]).
  • available reads Jolt’s live getter. On the Web it requires Pointer Events, (any-hover: hover) and a listening source. On NativeScript it reports the loaded view’s hover API (Android/iPad, not iPhone), without detecting a connected mouse. Disabled, hidden, suspended or reduced-motion input is unavailable. onAvailabilityChange(available) receives the initial state and later changes; write it to a Vue ref to hide or swap hover-only UI. Disposal reports false and removes the observation. The callback observes Jolt’s state; Jolt owns the presence reset when hover capability disappears.
  • execution is hover while input can arrive and static otherwise.

A recipe needs no platform branch: with no hover it holds its resting values. update({ disabled: true }) returns the controller to rest. The input is released when its scope or region is replaced, on KeepAlive deactivation, when the native view unloads and when the app goes to the background, and attaches once again when it comes back.

Vue Web · Chromium · 760 × 620 CSS pixels

Afterglow's card follows the pointer inside the region and leans while presence is 1. The dot marks the mouse: the recording has no system cursor, and the mouse is moved by a script.

Viewport entrances ​

Call region.viewportEnter(surfaces, options) once all surfaces and an optional MScreen scroll source are available. The group is an ordered list of 1–64 distinct identities. Options are frames, transition, stagger in milliseconds, root, margin in CSS pixels/DIPs, threshold, once and disabled. Positive margin expands the observed viewport. stagger delays the surfaces that enter together, in the order they arrive, so a surface that scrolls in on its own enters at once, on the Web and on NativeScript. Replace the group by disposing its controller and creating another.

Web uses Jolt's IntersectionObserver integration; NativeScript observes scroll/layout events and asks Jolt to play the same recipe. The Mac and Windows hosts judge entrances from their own layout frames, after each layout and when an MScreen scrolls (see Regions on desktop). Without root or a scroll source, the Web measures entrances against the browser viewport and NativeScript against the page's topmost view, which covers the same screen. Content is never hidden during SSR or while waiting for observation. No observer means readable static content. Leaving cancels a pending entrance; once: false rearms on reentry. Cleanup settles only the controller's remaining channels. This opt-in recipe does not change MReveal or its controlled show, focus and inert behavior.

Exiting collection items ​

In collections using animateLayout, removal updates data and focus immediately. The inert Web exit copy preserves the displayed state of supported inputs and selects, simple inline SVG shapes and literal CSS-generated text. Password and file inputs, live media and content beyond the capture budget leave immediately.

Shared identities ​

region.sharedLayout() owns a transition group. attach(surface, 'edition') registers an explicit identity, follows that surface's replacement, and returns a detach function. Call transition(() => { expanded.value = true }) to capture before the host's synchronous state change. Jolt waits for Vue/native layout; the host still owns state, navigation, focus and dismissal. The returned handle supports cancellation and a finished result (completed, cancelled, or unavailable, with a reason).

Use this for static card/text content and decoded images. Web presentation copies are inert and hidden from accessibility. Arbitrary form/media controls, custom elements, Shadow DOM and projective transforms are outside this capture contract; unavailable geometry or content leaves the final application content in place. Native snapshots have their own platform limits. This is not a router, general-purpose rasterizer, keyed-list FLIP API or cross-document transition.

The Afterglow example preserves its actual interactive root while changing content and dimensions, so keyboard focus remains on the real control. Applications replacing focused components must explicitly place focus in the new view.

Diagnostics ​

region.diagnostics({ development: true, identity: 'edition', maxEvents: 80 }) is an opt-in, pull-only developer tool. snapshot() identifies the region/session and returns Jolt's numeric target/owner IDs, channels, layers, reasons and resource counts. IDs belong to that diagnostic session, not application data or DOM IDs. kind: 'rest' means a retained pose, not an active animation. The event ring is bounded to 1–2000 entries. No form values, elements, native views, frame polling or process-global session are exposed.

Native execution: 'lifecycle-only' reports the region's owned resources; it does not claim Web channel telemetry or install Jolt's global native sampling inspector. Dispose diagnostics to stop collection; a detached final snapshot remains readable. Read an active host before and after removing an interaction to compare its baseline. A disposed snapshot describes the end of diagnostic observation, not a guarantee that an application-wide runtime has stopped.

Surface conflicts ​

On Web, when something outside Jolt writes a property a motion surface owns (an inline opacity, a CSS transition, another animation), the next call that checks ownership, such as animate or set, throws a WebSurfaceConflictError. Mavis keeps Jolt's details — element (a selector such as div#card, never the node), and each change's property, previous and current — and states the fix in Mavis terms: call surface.refresh() after an intended size or pivot change; for other properties, move the style to a wrapper or dispose the surface's playback and bindings, apply it, and start them again. The original Jolt error stays available as cause. Use isSurfaceConflict(error) from @getcortexlabs/mavis-web/experimental to recognise it. A conflict found while a frame is already running is reported by the browser as an uncaught error with Jolt's wording; Mavis never suppresses it. Cleanup failures are collected in an AggregateError whose message names each failure.

Afterglow's diagnostics are exposed only at /checks/lifecycles. The normal showcase contains product controls only.

Sheets inside animated content ​

Jolt RC.7 understands the modal top-layer boundary. MSelect and MSheet can therefore live inside a card with application scale or scroll-linked opacity. Focus, keyboard input, Escape and scroll ownership remain with Mavis. If motion setup fails, Sheet releases its partial motion resources and keeps a usable static dialog. Arbitrary transforms on the actual panel/input space remain unsupported.

Seek and rewind a scene ​

Declare one enclosing motion region and give each animated surface a stable reference. The scene takes finite numeric keyframes for transform and opacity, writable numbers created on those surfaces, and groups with offsets in milliseconds. A value can also drive a color binding. Pause the scene and set progress from 0 to 1 to inspect either endpoint, then rewind or resume. A later write owns its individual channel. Disposal of a participant or region stops the scene and releases its registrations. Jolt owns the clock on Web and NativeScript. With reduced motion enabled, spatial tracks settle at their destination. Scrubbing still updates opacity and the numeric value driving the decoration.

ts
const scene = region.seekableTimeline(
  [
    { target: cover, keyframes: { x: [-36, 36] }, transition: { duration: 1600 } },
    { value: tint, keyframes: [0, 1], transition: { duration: 1600 } },
    { at: 400, steps: [{ target: stamp, keyframes: { opacity: [0.4, 1] } }] },
  ],
  { paused: true },
)

scene.progress = 1
scene.progress = 0
scene.resume()

Open the shared scene.

Catalog recordings ​

The two surfaces share a clock. The scene seeks to both endpoints, then a new owner takes position and color before the last seek.

Chromium

iOS Simulator

Android emulator

Development inspection and editing ​

Import inspectMavisMotion from @getcortexlabs/mavis-web/inspector on Web or @getcortexlabs/mavis/inspector on NativeScript. Pass a declared region, { development: true } and a setup callback. Call watch to register a surface and track to register an application animation. Pause, play, seek and stop by its registered ID. The tune callback receives the spring settings the application can apply and copy. Disconnecting preserves the region’s existing diagnostic collector.

On Web, moving a mounted element outside the region ends inspection of its surface and playback on the next read, sample or control request. The application retains its playback.

On Web, sample, samples and plot read computed style on request. An unsupported transform leaves a gap in the plot. On native, select and read inspect the selected channel. Each synthetic drag checks positions 0, 80 and 120 and reports its remaining resources. The 64-read measurement covers elapsed JavaScript call time in that environment. Timing on a recent physical Android device remains open.

One English catalog run took 3.17 ms for 64 reads on the iOS simulator, 10.47 ms on the Android emulator, 2.40 ms in Chromium, 3.00 ms in Firefox and 2.00 ms in WebKit. These are local call-batch timings and depend on system load.

Open the catalog inspector.

iOS 26.2 simulator. Selected native channel, spring tuning and synthetic drag.
Android emulator. Seek by ID and verify the drag checkpoints.
Chromium. Computed-style observation, replay and on-demand measurement.

Components for NativeScript and Web. Starting with Vue.