rstacruz / nprogress

For slim progress bars like on YouTube, Medium, etc
http://ricostacruz.com/nprogress
MIT License
25.98k stars 1.81k forks source link

Help Combining NProgress with Barba JS #205

Open MrUltimate opened 6 years ago

MrUltimate commented 6 years ago

Hello,

Thanks for this amazing library. I quickly wanted to ask help on how I can combine this library with Barba.js? I see the implementation for TurboLinks but I don't quite understand how I can implement this with Barba.js's PJAX states.

Thanks in advance.

aswinkumar863 commented 5 years ago

Hello @MrUltimate ,

try this

NProgress.configure({ showSpinner: false });
Barba.Pjax.start();

var HideShowTransition = Barba.BaseTransition.extend({
    start: function () {
        this.newContainerLoading.then(this.finish.bind(this));
        NProgress.start();
    },
    finish: function () {
        NProgress.done();
        this.done();
    }
});
Barba.Pjax.getTransition = function () {
    return HideShowTransition;
};