Git Product home page Git Product logo

animatecss's Introduction

Animate CSS jQuery Plugin

A jQuery plugin to dynamically apply Dan Eden's animate.css animations with callbacks

Code Climate

Getting Started

Bower

Install with Bower bower install animateCSS

Download

Download the production version or the development version.

In your web page:

<script src="jquery.js"></script>
<script src="dist/animatecss.min.js"></script>
<script>
$(document).ready( function(){
  $('#your-id').animateCSS("fadeIn");
});
</script>

Documentation

{
  infinite: false, // True or False
  animationClass: "animated", // Can be any class
  delay: 0 // Can be any value (in ms)
  duration: 1000 // Can be any value (in ms)
  callback: // Any function
}

When using infinite: true and a delay, the delay will only occur before the first loop, not on every loop.

Examples

Basic

$('#your-id').animateCSS('fadeIn');

With callback

$('#your-id').animateCSS('fadeIn', function(){
    console.log('Boom! Animation Complete');
});

With delay (in ms)

$('#your-id').animateCSS('fadeIn', {delay: 500});

With delay AND callback

$('#your-id').animateCSS('fadeIn', {
  delay: 1000,
  callback: function(){
    console.log('Boom! Animation Complete');
  }
});

With duration (in ms)

$('#your-id').animateCSS('fadeIn', {duration: 3000});

Chain multiple animations

If you use the standard jQuery chaining mechanism, each animation will fire at the same time so you have to include the next animation in the callback.

$('#your-id').animateCSS('fadeInUp', function() {
  console.log('Boom! First animation Complete');
  $(this).animateCSS("fadeOutUp", function(){
    console.log('Boom Boom! Second animation Complete');
  })
});

Offset animations

You can offset animations by using the delay mechanism

$('#your-id').animateCSS('fadeIn');
$('#another-id').animateCSS('fadeIn', {delay:100});

If you want to hide an element when the page loads and then apply an effect, it might look something like this:

.js #your-id {
  visibility:hidden;
}
$(window).load( function(){
  $('#your-id').animateCSS('fadeIn', function(){
    console.log('Boom! Animation Complete');
  });
});

Release History

Please consult the official changelog

animatecss's People

Contributors

craigmdennis avatar martingg88 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

animatecss's Issues

Firefox issue..

I got issue with FF and it's look like the problem came from the CSS version.
Sorry my bald.

Three undocumented lines!

if (!$("html").hasClass("csstransforms")) {

        onEnd();

    }

these lines (63-67) cause animation to stop immediately.

Stopping current animated and start a different one.

Hi Is there any way to stop current running animations and start a different one. i.e.
I am animating a block out on a keypress but on another keypress before the first animation has finished I want to start a new animation that returns the bock to the initial position.

AMDfied

Require.js compatible

/*! animateCSS - v1.1.5 - 2014-05-27
* https://github.com/craigmdennis/animateCSS
* Copyright (c) 2014 Craig Dennis; Licensed MIT */


+(function (factory) {
	if (typeof define === "function" && define.amd) {		
		define(["jquery"], factory);
	} else {

		// Browser globals
		factory(jQuery);
	}
}(function ($) {
	'use strict';
   
	$.fn.extend({
		animateCSS: function(effect, options) {
			var addClass, animate, callback, complete, init, removeClass, settings, transitionEnd, unhide;
			settings = {
				effect: effect,
				delay: 0,
				animationClass: 'animated',
				infinite: false,
				callback: options,
				debug: false
			};
			transitionEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
			settings = $.extend(settings, options);
			init = function(element) {
				return animate(element);
			};
			animate = function(element) {
				if (settings.infinite === true) {
					settings.animationClass += ' infinite';
				}
				return setTimeout(function() {
					unhide(element);
					addClass(element);
					return complete(element);
				}, settings.delay);
			};
			addClass = function(element) {
				return element.addClass(settings.effect + ' ' + settings.animationClass + ' ');
			};
			unhide = function(element) {
				if (element.css('visibility') === 'hidden') {
					element.css('visibility', 'visible');
				}
				if (element.is(':hidden')) {
					return element.show();
				}
			};
			removeClass = function(element) {
				return element.removeClass(settings.effect + ' ' + settings.animationClass);
			};
			callback = function(element) {
				if (settings.infinite === false) {
					removeClass(element);
				}
				if (typeof settings.callback === 'function') {
					return settings.callback.call(element);
				}
			};
			complete = function(element) {
				return element.one(transitionEnd, function() {
					return callback(element);
				});
			};
			return this.each(function() {
				return init($(this));
			});
		}
	});

}))

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.