Multiple page timelines

Sometimes you just need that page transition to be different every time. To achieve this you can create multiple timelines for your page transitions. Here I'll demo a simple example of page transitions being based on route changes.

Note: Make sure your vue skeleton project is all set up and ready for page transitioning.

Create the pages

Open up the terminal in the same directory as the package.json and create the following pages:

sg transition-page AboutPage
sg transition-page ContactPage

After the pages have ben generated it's time to open up the src/data/enum/RoutePaths.js and add the new paths

const RoutePaths = {
  HOME: '/',
  ABOUT: '/about',
  CONTACT: '/contact',
};

export default RoutePaths;

Also add the new pages to the src/data/enum/RouteNames.js

const RouteNames = {
  HOME: 'home',
  ABOUT: 'about',
  CONTACT: 'contact',
};

export default RouteNames;

Finally update the src/router/routes.js file to enable the pages.

Create an AbstractPage

To make sure we don't have to apply this logic to all the pages we create an AbstractPage layer, keep in mind that when running the seng-generator to create an extra page this new page will NOT automatically extend this new page. If you want this you should create a custom seng-generator template for these type of pages but I will not go into this.

Note: Make sure this file is in the root of your src/page folder and have your HomePage.js, AboutPage.js and ContactPage.js extend this new page and provide the new transitionInId

Create an AbstractPageTransitionController

For the same reason as why we created the abstract page we should also create an AbstractPageTransitionController that handles all the transitions. If you have different animations for each page you should probably skip this step and do it custom in your page transition controller. But in this example all the pages use the same type of animations. So we create an abstract transition controller with default transitions in there.

Note: Make sure you update the HomePageTransitionController, AboutPageTransitionController and ContactPageTransitionController so they all extend this new class.

Configure the transitions

Now we are ready to configure the new transitions. We do this in the meta section of the router/routes.js file. The way it works is that the transition in describes the page that we came from and the transition out describes the page we are about to navigate to. If no matches are found it will fall back to the default transition. which is a fade in our case

Last updated