Created
January 9, 2016 16:48
-
-
Save frederikbosch/c689d034acb5de1f1ff4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from "ember"; | |
var RSVP = Ember.RSVP; | |
export default function () { | |
if (!this.newElement) { | |
return RSVP.resolve(); | |
} else if (!this.oldElement) { | |
this.newElement.css({visibility: ''}); | |
return RSVP.resolve(); | |
} | |
return new RSVP.Promise((resolve) => { | |
var tweenComplete = () => { | |
this.oldElement.css({ | |
visibility: 'hidden' | |
}); | |
this.newElement.css({ | |
visibility: '' | |
}); | |
resolve(); | |
}; | |
this.newElement.css({ | |
visibility: '' | |
}); | |
var timeline = new TimelineMax({ | |
onComplete: tweenComplete, | |
paused:true | |
}); | |
timeline.insert(TweenMax.fromTo(this.oldElement[0], 0.2, { x: 0}, {x: this.oldElement.width() * -1})); | |
timeline.insert(TweenMax.fromTo(this.newElement[0], 0.2, { x: this.oldElement.width()}, {x: 0})); | |
timeline.play(); | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from "ember"; | |
var RSVP = Ember.RSVP; | |
export default function () { | |
if (!this.newElement) { | |
return RSVP.resolve(); | |
} else if (!this.oldElement) { | |
this.newElement.css({visibility: ''}); | |
return RSVP.resolve(); | |
} | |
return new RSVP.Promise((resolve) => { | |
var tweenComplete = () => { | |
this.oldElement.css({ | |
visibility: 'hidden' | |
}); | |
this.newElement.css({ | |
visibility: '' | |
}); | |
resolve(); | |
}; | |
this.newElement.css({ | |
visibility: '' | |
}); | |
var timeline = new TimelineMax({ | |
onComplete: tweenComplete, | |
paused:true | |
}); | |
timeline.insert(TweenMax.fromTo(this.oldElement[0], 0.3, { x: 0}, {x: this.oldElement.width()})); | |
timeline.insert(TweenMax.fromTo(this.newElement[0], 0.3, { x: this.oldElement.width() * -1}, {x: 0})); | |
timeline.play(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment