diff --git a/.bowerrc b/.bowerrc new file mode 100644 index 0000000..6ad533f --- /dev/null +++ b/.bowerrc @@ -0,0 +1,3 @@ +{ + "directory": "src/bower_components" +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..5d415a3 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +tab_width = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..98a6a5b --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +node_modules +bower_components +/.tmp +/test +.DS_Store diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..46bbeb9 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,22 @@ +{ + "node": true, + "browser": true, + "esnext": true, + "bitwise": true, + "camelcase": true, + "curly": true, + "eqeqeq": true, + "immed": true, + "indent": 2, + "latedef": true, + "newcap": true, + "noarg": true, + "quotmark": "single", + "regexp": true, + "undef": true, + "unused": true, + "strict": true, + "trailing": true, + "smarttabs": true, + "jquery": true +} diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..2cdacaf --- /dev/null +++ b/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - '0.10' + - '0.8' diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..7c9d9d3 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,101 @@ + +### 1.2.1 (2015-03-23) + + + +## 1.2.0 (2015-03-23) + +#### Features + +* add animation duration option ([e1ef7983](https://github.com/craigmdennis/animatecss/commit/e1ef7983c25fec49254611ca4e19a88e5f4b1422)) + + + +### 1.1.5 (2014-05-27) + + + +### 1.1.4-0 (2014-05-27) + + + +### 1.1.3-1 (2014-05-21) + + + +### 1.1.3-0 (2014-05-21) + + +#### Bug Fixes + +* stop grunt-bump from trying to bump the CHANGELOG.md ([d06d4126](https://github.com/craigmdennis/animateCSS/commit/d06d4126731efbb8b01f8926d22a9c86bc337757)) + + + +### 1.1.2-2 (2014-05-21) + +#### Bug Fixes + +* Remove private flag to allow Bower registration + + + +### 1.1.2-2 (2014-05-21) + + + +### 1.1.2-1 (2014-05-21) + + + +### 1.1.2 (2014-05-21) + + + +### 1.1.0 (2014-05-21) + + +#### Features + +* add the ability to use animation loops ([b477632b](https://github.com/craigmdennis/animatecss/commit/b477632bc87f6d96d7ed2fd0ced0aec296c35952)) + + +#### Breaking Changes + +* Delay can no longer be specified in the plugin shorthand ([89e7da1a](https://github.com/craigmdennis/animatecss/commit/89e7da1af66ba58c0078b426353b281b227c6844)) + +Before: + +`$('#your-id').animateCSS('fadeIn', 2000);` + +After: + +`$('#your-id').animateCSS('fadeIn', {delay:2000});` + + + +### 1.0.6 (2013-10-30) + + + +### 1.0.5 (2013-10-20) + + + +### 1.0.4 (2013-01-18) + + + +### 1.0.3 (2013-10-20) + + + +### 1.0.2 (2013-10-20) + + + +### 1.0.1 (2013-10-17) + + + +### 1.0.0 (2012-11-26) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..17f3c43 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,26 @@ +# Contributing + +## Important notes +Please don't edit files in the `dist` subdirectory as they are generated via Grunt. You'll find source code in the `src` subdirectory! + +### Code style +Regarding code style like indentation and whitespace, **follow the conventions you see used in the source already.** + +## Modifying the code +First, ensure that you have the latest [Node.js](http://nodejs.org/) and [npm](http://npmjs.org/) installed. + +Test that Grunt's CLI and Bower are installed by running `grunt --version` and `bower --version`. If the commands aren't found, run `npm install -g grunt-cli bower`. For more information about installing the tools, see the [getting started with Grunt guide](http://gruntjs.com/getting-started) or [bower.io](http://bower.io/) respectively. + +1. Fork and clone the repo. +1. Run `npm install` to install all build dependencies (including Grunt). +1. Run `bower install` to install the front-end dependencies. +1. Run `grunt` to grunt this project. + +Assuming that you don't see any red, you're ready to go. Just be sure to run `grunt` after making any changes, to ensure that nothing is broken. + +## Submitting pull requests + +1. Create a new branch, please don't work in your `master` branch directly. +1. Fix stuff. +1. Update the documentation to reflect any changes. +1. Push to your fork and submit a pull request. diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..ae7c424 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,175 @@ +'use strict'; + +module.exports = function (grunt) { + // Load all grunt tasks + require('load-grunt-tasks')(grunt); + // Show elapsed time at the end + require('time-grunt')(grunt); + + // Project configuration. + grunt.initConfig({ + // Metadata. + pkg: grunt.file.readJSON('package.json'), + banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' + + '<%= grunt.template.today("yyyy-mm-dd") %>\n' + + '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' + + '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' + + ' Licensed MIT */\n\n', + // Task configuration. + clean: { + files: ['dist', '.tmp'] + }, + + concat: { + options: { + banner: '<%= banner %>', + stripBanners: true + }, + dist: { + src: ['.tmp/<%= pkg.name %>.js'], + dest: 'dist/jquery.<%= pkg.name %>.js' + } + }, + + uglify: { + options: { + banner: '<%= banner %>' + }, + dist: { + src: '<%= concat.dist.dest %>', + dest: 'dist/jquery.<%= pkg.name %>.min.js' + } + }, + + jade: { + options: { + pretty: true + }, + dist: { + files: [{ + expand: true, + cwd: 'test/', + dest: '.tmp/', + src: '*.jade', + ext: '.html' + }] + }, + }, + + coffee: { + dist: { + files: [{ + expand: true, + cwd: 'src', + src: '{,*/}*.coffee', + dest: '.tmp/', + ext: '.js' + }] + } + }, + + jshint: { + options: { + reporter: require('jshint-stylish') + }, + gruntfile: { + options: { + jshintrc: '.jshintrc' + }, + src: 'Gruntfile.js' + }, + dist: { + options: { + jshintrc: '.jshintrc' + }, + src: ['.tmp/{,*/}*.js'] + } + }, + + watch: { + gruntfile: { + files: '<%= jshint.gruntfile.src %>', + tasks: ['jshint:gruntfile'] + }, + jade: { + files: ['test/*.jade'], + tasks: ['jade'] + }, + coffee: { + files: ['src/{,*/}*.coffee'], + tasks: ['coffee'] + }, + livereload: { + options: { + livereload: '<%= connect.options.livereload %>' + }, + files: [ + '.tmp/{,*/}*.*', + ] + } + }, + + bump: { + options: { + files: ['package.json', 'bower.json', '<%= pkg.name %>.jquery.json'], + push: true, + pushTo: 'origin', + createTag: true, + tagName: 'v%VERSION%', + tagMessage: 'Version %VERSION%', + commitFiles: ['<%= bump.options.files %>', 'CHANGELOG.md'], + commitMessage: 'Bumped version to v%VERSION%' + } + }, + + changelog: { + options: { + editor: 'atom -w' + } + }, + + connect: { + options: { + hostname: '0.0.0.0', + livereload: 35729, + port: 9000 + }, + livereload: { + options: { + open: true, + base: [ + '.tmp/', + 'src/' + ] + } + }, + } + }); + + // Default task. + grunt.registerTask('default', [ + 'clean', + 'compile', + 'jshint:dist', + 'concat', + 'uglify', + ]); + + // Compile Jade and CoffeeScript + grunt.registerTask('compile', [ + 'newer:coffee', + 'newer:jade' + ]); + + // Server task + grunt.registerTask('server', function () { + grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.'); + grunt.task.run(['serve']); + }); + + grunt.registerTask('serve', [ + 'compile', // jade, coffeescript + 'connect', + 'watch' + ]); +}; diff --git a/LICENCE b/LICENCE index ec3184b..4178530 100644 --- a/LICENCE +++ b/LICENCE @@ -1,4 +1,4 @@ -Copyright (c) 2013 Craig Dennis +Copyright (c) 2014 Craig Dennis Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index 8248133..ff58df4 100644 --- a/README.md +++ b/README.md @@ -1,44 +1,120 @@ -Use the animate.css animations from http://daneden.me/animate/ +# Animate CSS jQuery Plugin -## USAGE: +A jQuery plugin to dynamically apply [Dan Eden's animate.css][animate.css] animations with callbacks -Basic -
+[animate.css]: http://daneden.github.io/animate.css/
+
+[](https://codeclimate.com/github/craigmdennis/animateCSS)
+
+## Getting Started
+
+### Bower
+Install with [Bower][bower]
+`bower install animateCSS`
+
+[bower]: http://bower.io/
+
+### Download
+
+Download the [production version][min] or the [development version][max].
+
+[min]: https://raw.github.com/craigmdennis/animateCSS/master/dist/jquery.animatecss.min.js
+[max]: https://raw.github.com/craigmdennis/animateCSS/master/dist/jquery.animatecss.js
+
+In your web page:
+
+```html
+
+
+
+```
+
+## Documentation
+
+```js
+{
+ 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
+```js
$('#your-id').animateCSS('fadeIn');
-
+```
-With callback
-
+### With callback
+```js
$('#your-id').animateCSS('fadeIn', function(){
- alert('Boom! Animation Complete');
+ console.log('Boom! Animation Complete');
+});
+```
+
+### With delay (in ms)
+```js
+$('#your-id').animateCSS('fadeIn', {delay: 500});
+```
+
+### With delay AND callback
+```js
+$('#your-id').animateCSS('fadeIn', {
+ delay: 1000,
+ callback: function(){
+ console.log('Boom! Animation Complete');
+ }
});
-
+```
-With delay (in ms)
-
-$('#your-id').animateCSS('fadeIn', 500);
-
+### With duration (in ms)
+```js
+$('#your-id').animateCSS('fadeIn', {duration: 3000});
+```
-With delay AND callback
-
-$('#your-id').animateCSS('fadeIn', 1000, function(){
- alert('Boom! Animation Complete');
+### 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.
+```js
+$('#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
+```js
+$('#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:
-
-<style>
- .js #your-id {
- visibility:hidden;
- }
-</style>
+```css
+.js #your-id {
+ visibility:hidden;
+}
+```
+```js
$(window).load( function(){
- $('#your-id').animateCSS('fadeIn', 1000, function(){
- alert('Boom! Animation Complete');
- });
+ $('#your-id').animateCSS('fadeIn', function(){
+ console.log('Boom! Animation Complete');
+ });
});
-
+```
+
+## Release History
+Please consult the official [changelog][changelog]
-Remember to use a .js (or .no-js depending on how you role) so that the element still displays for non javascript users (and Google previews).
\ No newline at end of file
+[changelog]: https://github.com/craigmdennis/animateCSS/blob/master/CHANGELOG.md
diff --git a/animateCSS.jquery.json b/animateCSS.jquery.json
index 00f246e..c10e1db 100644
--- a/animateCSS.jquery.json
+++ b/animateCSS.jquery.json
@@ -1,28 +1,31 @@
{
- "name": "animateCSS",
- "title": "jQuery animateCSS",
- "description": "A jQuery plugin to dynamically apply animate.css animations with callbacks",
- "keywords": [
- "animation",
- "CSS3",
- "callbacks"
- ],
- "version": "1.0.4",
- "author": {
- "name": "Craig Dennis",
- "url": "https://github.com/craigmdennis",
- "email": "hello@craigmdennis.com"
- },
- "licenses": [
- {
- "type": "MIT",
- "url": "https://github.com/craigmdennis/animateCSS/blob/master/LICENCE"
- }
- ],
- "bugs": "https://github.com/craigmdennis/animateCSS/issues",
- "homepage": "https://github.com/craigmdennis/animateCSS",
- "docs": "https://github.com/craigmdennis/animateCSS",
- "dependencies": {
- "jquery": ">=1.5.0"
+ "name": "animateCSS",
+ "title": "Animate CSS jQuery Plugin",
+ "description": "A jQuery plugin to dynamically apply animate.css animations with callbacks",
+ "version": "1.2.1",
+ "homepage": "https://github.com/craigmdennis/animateCSS.git",
+ "author": {
+ "name": "Craig Dennis",
+ "url": "https://github.com/craigmdennis"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/craigmdennis/animateCSS.git"
+ },
+ "bugs": "https://github.com/craigmdennis/animateCSS/issues",
+ "licenses": [
+ {
+ "type": "MIT",
+ "url": "http://opensource.org/licenses/MIT"
}
-}
\ No newline at end of file
+ ],
+ "dependencies": {
+ "jquery": "~1.11.0"
+ },
+ "keywords": [
+ "jquery-plugin",
+ "animation",
+ "callbacks",
+ "css3"
+ ]
+}
diff --git a/animateCSS.js b/animateCSS.js
deleted file mode 100644
index 7ed013d..0000000
--- a/animateCSS.js
+++ /dev/null
@@ -1,82 +0,0 @@
-(function ($) {
-
- $.fn.animateCSS = function (effect, delay, callback) {
-
- // Return this to maintain chainability
- return this.each(function () {
-
- // Cache $(this) for speed
- var $this = $(this);
-
- // Create a function we can call later
- function run() {
-
- // Add the animation effect with classes
- $this.addClass('animated ' + effect);
-
- // Check if the elemenr has been hidden to start with
- if ($this.css('visibility') == 'hidden') {
-
- // If it has, show it (after the class has been added)
- $this.css({
- 'visibility': 'visible'
- });
-
- }
-
- // If the element is hidden
- if ($this.is(':hidden')) {
-
- // Show it
- $this.show();
-
- }
-
- // Event triggered when the animation has finished
- $this.bind('animationend webkitAnimationEnd oAnimationEnd', function () {
-
- // Remove the classes so they can be added again later
- $this.removeClass('animated ' + effect);
-
- // Add a callback event
- if (typeof callback == 'function') {
-
- // Execute the callback
- callback.call(this);
-
- // Unbind the event handlers
- $this.unbind('animationend webkitAnimationEnd oAnimationEnd');
-
- }
-
- });
-
- }
-
- // Check if delay exists or if it's a callback
- if (!delay || typeof delay == 'function') {
-
- // If it's a callback, move it to callback so we can call it later
- callback = delay;
-
- // Run the animation (without delay)
- run();
-
- } else {
-
- // Start a counter so we can delay the animation if required
- var animation = setTimeout(function () {
-
- // Run the animation (with delay)
- run();
-
- // Specify the delay
- }, delay);
-
- }
-
- });
-
- };
-
-})(jQuery);
\ No newline at end of file
diff --git a/bower.json b/bower.json
new file mode 100644
index 0000000..b04df3b
--- /dev/null
+++ b/bower.json
@@ -0,0 +1,31 @@
+{
+ "name": "animateCSS",
+ "description": "A jQuery plugin to dynamically apply animate.css animations with callbacks",
+ "main": "dist/jquery.animatecss.js",
+ "version": "1.2.1",
+ "dependencies": {
+ "animate.css": "~3.1.1"
+ },
+ "devDependencies": {
+ "jquery": "~1.11.0"
+ },
+ "homepage": "https://github.com/craigmdennis/animateCSS",
+ "authors": [
+ "Craig Dennis