Hi guys,
So I got things working perfectly now using Animsition and CSS animations but I notice some performance issues that slow down the animations from time to time. Since I'm very interested in Barba I started integrating this on a testsite but am a bit confused as to how I can integrate the Tweenmax functions.
When I use the standard Barba fade transition it works flawless, but I can't seem to figure out how to change the standard fade transitions to the Tweenmax transitions.
This is the standard Barba transition:
var FadeTransition = Barba.BaseTransition.extend({
start: function() {
/**
* This function is automatically called as soon the Transition starts
* this.newContainerLoading is a Promise for the loading of the new container
* (Barba.js also comes with an handy Promise polyfill!)
*/
// As soon the loading is finished and the old page is faded out, let's fade the new page
Promise
.all([this.newContainerLoading, this.fadeOut()])
.then(this.fadeIn.bind(this));
},
fadeOut: function() {
/**
* this.oldContainer is the HTMLElement of the old Container
*/
return $(this.oldContainer).animate({ opacity: 0 }).promise();
},
fadeIn: function() {
/**
* this.newContainer is the HTMLElement of the new Container
* At this stage newContainer is on the DOM (inside our #barba-container and with visibility: hidden)
* Please note, newContainer is available just after newContainerLoading is resolved!
*/
var _this = this;
var $el = $(this.newContainer);
$(this.oldContainer).hide();
$el.css({
visibility : 'visible',
opacity : 0
});
$el.animate({ opacity: 1 }, 400, function() {
/**
* Do not forget to call .done() as soon your transition is finished!
* .done() will automatically remove from the DOM the old Container
*/
_this.done();
});
}
});
/**
* Next step, you have to tell Barba to use the new Transition
*/
Barba.Pjax.getTransition = function() {
/**
* Here you can use your own logic!
* For example you can use different Transition based on the current page or link...
*/
return FadeTransition;
};
Now I want to integrate the following into the above for the fadeout of the page (when a link is clicked and the site goes to a new page, before the new page starts loading):
TweenMax.to(".overlay-black", 1.2, {height:'100%', ease:Power4.easeInOut});
TweenMax.to(".overlay-yellow", 1.4, {height:'100%', ease:Power4.easeInOut});
TweenMax.to(".overlay-white", 1.6, {height:'100%', ease:Power4.easeInOut});
And for the fade-in after the new page has loaded
TweenMax.to(".overlay-black", 1.6, {height:'0', ease:Power4.easeInOut});
TweenMax.to(".overlay-yellow", 1.4, {height:'0', ease:Power4.easeInOut});
TweenMax.to(".overlay-white", 1.2, {height:'0', ease:Power4.easeInOut});
Now the Tweenmax functions probably have to go in a timeline first? And after, any idea how I can integrate the functions into the Barba functions that handle the transitions?
As you have noticed my JS is very basic and I still have a lot to learn (working on it), so it would be great if someone can help me out.
Thanks!