Barba: Fade out/in pure javascript

Created on 10 Sep 2018  路  1Comment  路  Source: barbajs/barba

Hey,
If I understood correctly Barba Js no need jQuery library to work; could somebody help me and change the following code for pure javascript that works without jquery library:

var FadeTransition = Barba.BaseTransition.extend({
                start: function() {
                    Promise
                        .all([this.newContainerLoading, this.fadeOut()])
                        .then(this.fadeIn.bind(this));
                },

                fadeOut: function() {
                    $(this.oldContainer).toggleClass('fade-out');

                    return new Promise(function(resolve, reject) {
                        window.setTimeout(function() {
                            resolve();
                        }, 700);
                    });
                },
                fadeIn: function() {
                    $(this.newContainer).toggleClass('fade-in');
                    this.done();
                }
            });

            Barba.Pjax.getTransition = function() {
                return FadeTransition;
            };

I'm very grateful for your help.

Most helpful comment

```
var FadeTransition = Barba.BaseTransition.extend({
start: function () {
Promise
.all([this.newContainerLoading, this.fadeOut()])
.then(this.fadeIn.bind(this));
},

fadeOut: function () {
    var oldWrap = this.oldContainer;
    oldWrap.classList.toggle('fade-out');

    return new Promise(function (resolve, reject) {
        window.setTimeout(function () {
            resolve();
        }, 700);
    });
},
fadeIn: function () {
    var newWrap = this.newContainer;
    newWrap.classList.toggle('fade-in');
    this.done();
}

});

Barba.Pjax.getTransition = function () {
return FadeTransition;
};

>All comments

```
var FadeTransition = Barba.BaseTransition.extend({
start: function () {
Promise
.all([this.newContainerLoading, this.fadeOut()])
.then(this.fadeIn.bind(this));
},

fadeOut: function () {
    var oldWrap = this.oldContainer;
    oldWrap.classList.toggle('fade-out');

    return new Promise(function (resolve, reject) {
        window.setTimeout(function () {
            resolve();
        }, 700);
    });
},
fadeIn: function () {
    var newWrap = this.newContainer;
    newWrap.classList.toggle('fade-in');
    this.done();
}

});

Barba.Pjax.getTransition = function () {
return FadeTransition;
};

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iamtompickering picture iamtompickering  路  3Comments

luglio7 picture luglio7  路  4Comments

ProdesignerAgency picture ProdesignerAgency  路  3Comments

shanewmurphy picture shanewmurphy  路  3Comments

3oax picture 3oax  路  4Comments