gustavobg / knockout.animate

Animate.css custom binding for Knockout.js

Home Page:http://dnbard.github.io/knockout.animate

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

knockout.animate

Animate.css custom binding for Knockout.js

animate.css is a bunch of cool, fun, and cross-browser animations for you to use in your projects now with support of Knockout.js. Great for emphasis, home pages, sliders, and general just-add-water-awesomeness.

Installing

Download knockout.animate.min.js and all dependencies (animate.css, knockout.js) or use Bower command:

bower install knockout.animate

Usage

To use knockout.animate in your website, simply drop the animate.css, knockout.js and knockout.animate.js into your document's :

<head>
  <link rel="stylesheet" href="animate.min.css">
  <script type="text/javascript" src="knockout.min.js"></script>
  <script type="text/javascript" src="knockout.animate.min.js"></script>
</head>

Then add next data-binding to an element:

<div data-bind="animate:{ animation: 'zoomIn', state: true"></div>

That's it! You've got a CSS animated element. Super!

Use observable to control animation

You can control when animation is going to happen by assigning Knockout Observable to state field:

<div data-bind="animate:{ animation: 'zoomIn', state: state"></div>
function Viewmodel(){
  this.state = ko.observable(true);
}

ko.applyBindings(new Viewmodel());

Animation will be played when observable become true.

Assign in and out states and toggle between them

You can add in and out animation this way:

<div data-bind="animate:{ animation: ['zoomIn', 'zoomOut'], state: state"></div>

First animation will be played when state field become true and second when false.

Assign custom handler on state change

<div data-bind="animate:{ animation: 'zoomIn', state: state, handler: handler"></div>
function Viewmodel(){
  this.state = ko.observable(true);
  
  this.handler = function(event, state){
    //do something here
  }
}

ko.applyBindings(new Viewmodel());

About

Animate.css custom binding for Knockout.js

http://dnbard.github.io/knockout.animate


Languages

Language:JavaScript 59.5%Language:HTML 25.6%Language:CSS 14.9%