Skip to main content

ViewJsonAnimator

What is ViewJsonAnimator?

ViewJsonAnimator is a lightweight, high-performance animator that updates SceneGraph renderer fields directly from one set of values to another. It operates on a map of view IDs to renderer instances and animates field values over time. This makes it ideal for simple property animations where you know the renderer and fields to tween.

Key features:

  • Animates one or many SG nodes at once using JSON maps
  • Supports repeat and reverse
  • Can start from current renderer values
  • Fixed-step timing tuned for Roku performance

Core API (summary)

  • animateTo(values, duration, options?): Start/retarget with { viewId: { field: value } } maps.
  • start(resume?, useCurrentState?): Begin; optionally sample current values.
  • stop(), pause(), resume().

Live Example

Try It

Press Pulse to widen and flash the rectangle using reverse; press Blue to restore its color.

Tip: Use Current State

Pass useCurrentState: true to avoid jumps when retargeting mid-animation.

  • animateTo(values, duration, options?): set new targets; can repeat and reverse.
  • start(resume?, useCurrentState?): begin or resume; optionally sample current values.
  • stop(), pause(), resume().

Single-view convenience: ViewAnimator

If you want to animate a single renderer, use ViewAnimator (a thin wrapper over ViewJsonAnimator).

Sequence

ViewJsonAnimator sequence

Also note: BaseView.animateTo helper

At the view level, BaseView exposes efficient renderer updates. For orchestrated, state-driven animations across many views, prefer HosannaViewAnimator.

Caution: Avoid Conflicts

Stop or retarget existing animations before launching new ones on the same view to avoid tug-of-war.