Giter Site home page Giter Site logo

animation-router's Introduction

animation-router

A JavaScript UI router for creating ambitious transitions between application states

Goals

In many of my applications, I aim to do somewhat ambitious transitions between application states or views.

Instead of just a quick fadeOut or slideIn, I may want to time specific elements to take more interesting actions, individually.

However, in a large application, this can quickly become a mess.

So, I created a small object that could transition between any two routes by calling the appropriate setup and teardown scripts, respectively.

Dependencies

The router itself has no dependencies. However, the example is designed for jQuery.

Getting Started

After including animation-router.js in your project, you will have a router object.

You can use this to register your routes, and transition to a new route.

Registering a route

There are many examples provided, however, the basic pattern resembles this:

/**
 * Facilitate transitions for the Main Menu
 */
router.defineRoute('main-menu', {

    // Executes each time we load the `main-menu` route
    load: function () {
        // You execute some code here
    },

    // Executes each time we unload the route
    unload: function () {
        // You execute some code here
    }
});

This gives you a route named main-menu, which has an optional setup and teardown script that executes arbitrary code when performing a route transition.

Transitioning

It is very simple to transition between routes.

The router object remembers the name of the current route, so you only need to provide the route you wish to transition to.

For example:

router.transitionTo('main-menu')

Would transition your app into the main-menu route.

animation-router's People

Contributors

kidgodzilla avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.