Giter Site home page Giter Site logo

chensheng1357 / angular-ui-router-anim-in-out Goto Github PK

View Code? Open in Web Editor NEW

This project forked from homerjam/angular-ui-router-anim-in-out

0.0 1.0 0.0 3.98 MB

An animation directive to use with ngAnimate 1.2+ and ui-router

Home Page: http://homerjam.github.io/angular-ui-router-anim-in-out/

angular-ui-router-anim-in-out's Introduction

angular-ui-router-anim-in-out

An animation directive to use with ngAnimate 1.2+ and ui-router

Installation

$ bower install angular-ui-router-anim-in-out --save

Quick Start

  • Include anim-in-out.js & anim-in-out.css on the page
  • Include module as a dependency of your app
angular.module('ExampleApp', ['ngAnimate', 'ui.router', 'anim-in-out'])
  • Configure states as per ui-router instructions
  • Add the animation directive anim-in-out to your ui-view elements by applying the class anim-in-out
<div ui-view="mainView" class="anim-in-out"></div>
  • Finally add classes from the anim-in-out.css to any elements you wish to transition on state change eg. anim-fade, anim-slide-left
<div ui-view="mainView" class="anim-in-out anim-fade" data-anim-speed="1000">

    <!-- Dynamically loaded view content -->
    
    <div class="my-component anim-slide-left"></div>

</div>

Usage

Animations are triggered by javascript in order to provide events.

// In your main controller
$rootScope.$on('animStart', function($event, element, speed) {
    // do something
});
    
$rootScope.$on('animEnd', function($event, element, speed) {
    // do something
});
    
    
// In your state controllers
$scope.$on('animIn', function($event, element, speed) {
    // do something
});
    
$scope.$on('animOut', function($event, element, speed) {
    // do something, eg. scroll to top of page
});

The default transition speed is 1000ms this can be altered using the data-anim-speed attribute on the ui-view. This is optionally further customised by the data-anim-in-speed and data-anim-out-speed attributes.

By default the animation of the incoming state will be triggered after a delay (data-anim-speed / data-anim-in-speed), but this can be changed by setting the attribute data-anim-sync to true.

<div ui-view="mainView" class="anim-in-out" data-anim-sync="true"></div>

Compile Sass

# Install gulp and dependencies
$ npm install

# Compile sass
$ gulp sass

Demo

http://homerjam.github.io/angular-ui-router-anim-in-out/

You may also like

angular-gsapify-router โ€” a similar directive that uses GSAP to power transitions; also features fine grained configuration using a priority attached to each state.

angular-ui-router-anim-in-out's People

Contributors

homerjam avatar

Watchers

 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.