Guide · Driver

Zumly with Motion

A driver decides how views move; Zumly decides where. This one runs the zooms on Motion: same views, same timing, Motion draws the frames.

Live example · MotionOpen ↗

Open a planet and come back. The ease is Motion's own, so the zoom moves differently from the default driver.

Do you need it?

Probably not to start. The default css driver is small and smooth, and every driver follows the same curve for the same ease. Use this one when:

With a script tag

Load Motion before Zumly and name the driver:

<script src="https://cdn.jsdelivr.net/npm/motion@11/dist/motion.js"></script>
<script src="https://unpkg.com/zumly/dist/zumly.js"></script>
const app = new Zumly({
  mount: '.canvas',
  initialView: 'home',
  views,
  transitions: { driver: 'motion', duration: '700ms', ease: 'backOut' }
})

With a bundler

There is no global, so hand the library to the driver:

import { animate } from 'motion'
import Zumly, { motionDriver } from 'zumly'

const app = new Zumly({
  mount: '.canvas',
  initialView: 'home',
  views,
  transitions: { driver: motionDriver({ animate }), duration: '700ms' }
})

Easing

What it animates

MoveWith Motion
Zoom in, zoom out, several levels outAnimated, with effects and stagger
Siblings (lateral)Animated: the same slide and fade as the css and waapi drivers
Zoom-out that follows a gestureWorks the same as with any driver

Wrapping it

A driver is a function, so you can wrap one:

const animated = motionDriver({ animate })

transitions: {
  driver: (spec, onComplete) => {
    console.log(spec.type)          // 'zoomIn', 'zoomOut' or 'lateral'
    animated(spec, onComplete)
  }
}

The full contract is in Write your own driver.

Things to know

Next

Timing, effects and gestures in step 6. The other drivers: GSAP · Anime.js · your own.

Open this example ↗ Learn in six steps