* { box-sizing: border-box; }
body {
  background-color: #333;
}
.boxes {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  width: 45%;
  margin: .3em;
  border-bottom: 1px dashed #fefefe;
  padding-bottom: .5em;
}
.box {
  width: 20px;
  height: 20px;
  background-color: #2f9e44;
  border-radius: 3px;
  display: inline-block;
  margin: .3em;
  opacity: 0;
}

.title {
  color: #fefefe;
  font-size: .875rem;
  font-family: monospace;
}
const INTERVAL = 300
const TRANSLATE_X = 20

function Boxes(vnode) {
  const arr = [1, 2, 3, 4, 5]
  const oncreate = _ => anime({
    targets: vnode.dom.querySelectorAll('.box'),
    translateX: arr.length * TRANSLATE_X,
    opacity: 1,
    loop: true,
    easing: vnode.attrs.easing,
    duration: (el, i) => i * INTERVAL + INTERVAL
  })
  
  const view = _ => m('.boxes',
    m('h1.title', vnode.attrs.easing),
    arr.map(_ => m('.box'))
  )

  return { view, oncreate }
}

function App(vnode) {
  const eases = [
    'easeInQuad',
    'easeInCubic',
    'easeInQuart',
    'easeInQuint',
    'easeInSine',
    'easeInExpo',
    'easeInCirc',
    'easeInBack',
    'easeInElastic',
    'easeOutQuad',
    'easeOutCubic',
    'easeOutQuart',
    'easeOutQuint',
    'easeOutSine',
    'easeOutExpo',
    'easeOutCirc',
    'easeOutBack',
    'easeOutElastic',
    'easeInOutQuad',
    'easeInOutCubic',
    'easeInOutQuart',
    'easeInOutQuint',
    'easeInOutSine',
    'easeInOutExpo',
    'easeInOutCirc',
    'easeInOutBack',
    'easeInOutElastic',
  ]
  const view = _ => {
    return eases.map(easing => m(Boxes, { easing }))
  }
  
  return { view }
}

m.mount(document.body, App)
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/mithril/1.1.3/mithril.min.js
  2. https://cdnjs.cloudflare.com/ajax/libs/animejs/2.0.2/anime.min.js