jQuery: eliminate white screen “pause” between animations

后端 未结 3 1163
陌清茗
陌清茗 2020-12-11 09:54

I have just discovered Barba.js and find it very useful. It provides smooth transitions between URLs of the same website.

I have put together a

3条回答
  •  萌比男神i
    2020-12-11 10:38

    I came out with this version of the script:

    $(function(){
        var transEffect = Barba.BaseTransition.extend({
        start: function() {
          this.newContainerLoading.then(val => this.fadeInNewcontent($(this.newContainer)));
        },
        fadeInNewcontent: function(nc) {
          var _this = this;
          nc.css('visibility', 'visible');
          nc.show().promise().done(() => {
            $(this.oldContainer).fadeOut(50);
            if (!isMobile.any()) {
              $('html, body').delay(100).animate({
                scrollTop: 200
              },700);
            }
          });
        }
      });
      Barba.Pjax.getTransition = function() {
        return transEffect;
      }
      Barba.Pjax.start();
    });
    

    It is better, but not smooth enough. See the the effect on a real life project. How can I improve it?

提交回复
热议问题