import { animate, Promise } from "liquid-fire";

export default function flyTo(opts={}) {
  if (!this.newElement) {
    return Promise.resolve();
  } else if (!this.oldElement) {
    this.newElement.css({visibility: ''});
    return Promise.resolve();
  }

  var oldOffset = this.oldElement.offset();
  var newOffset = this.newElement.offset();

  var motion = {
    translateX: newOffset.left - oldOffset.left,
    translateY: newOffset.top - oldOffset.top,
    width: this.newElement.width(),
    height: this.newElement.height()
  };

  this.newElement.css({ visibility: 'hidden' });
  return animate(this.oldElement, motion, opts).then(() => {
    this.newElement.css({ visibility: ''});
  });
}

@@ -456,17 +456,22 @@
 op,%0A    
-w
+outerW
 idth: th
@@ -484,17 +484,22 @@
 Element.
-w
+outerW
 idth(),%0A
@@ -502,17 +502,22 @@
 (),%0A    
-h
+outerH
 eight: t
@@ -531,17 +531,22 @@
 Element.
-h
+outerH
 eight()%0A

fix fly-to using my velocity PR