estrattonbailey / operator

1.8kb drop-in "PJAX" solution for fluid, smooth transitions between pages.
90 stars 11 forks source link

Create API to optionally provide custom animations? #7

Closed estrattonbailey closed 6 years ago

estrattonbailey commented 7 years ago

Could pass an option with methods as the return value from a route handler.

...
// line 42 index.js
  function render (markup, pathname, customAnimation) {
    const mountNode = document.getElementById(root)
    const oldDom = document
...

Would need to provide something like this

const customAnimation = {
  onBeforeRender () {
    return new Promise((res, rej) => {
      // do work
      res(null)
    })
  },
  onAfterRender () {
    return new Promise((res, rej) => {
      // same
      res(null)
    })
  }
}
estrattonbailey commented 6 years ago

v4 (unreleased) already includes this