Is it possible to show both the new and old pages simultaneously?

前端 未结 2 1324
不知归路
不知归路 2021-01-15 20:43

I\'m trying to build an effect like this for smoothstate: http://tympanus.net/Development/PageTransitions/, specifically the \"room\" transitions.

I\'m getting stuck

2条回答
  •  耶瑟儿~
    2021-01-15 21:20

    Hope you still need it. That's how I implemented this:

    $(function () {
        //'use strict';
        var $page = $('.m-scene'),
          options = {
              debug: true,
              onStart: {
                  duration: 0,
                  render: function ($container) {
    
                      $('.m-page.temp').remove(); //make sure we don't have more than two `pages` at a time
                      $('#move').removeClass('slideup'); //remove old animation; #move is the wrapper for original and injected content
                      $container.find('.m-page').addClass('temp'); //mark original content for removal
                  }
              },
              onReady: {
                  duration: 50, //prevents flickering of content 
                  render: function ($container, $newContent) {
                      $('#move').append($newContent.find('.m-page')); //select only stuff you actually need injected
                  }
              },
              onAfter: function ($container, $newContent) {
                    var target = $('#move');
                    animate(target); //it's animation time!
              }
          },
          smoothState = $page.smoothState(options).data('smoothState');
    });
    
    function animate(target) {
        target.addClass('slideup'); //add animation class
    }
    

提交回复
热议问题