An open API service indexing awesome lists of open source software.

https://github.com/intersel/ifsmanimation

iFSMAnimation allows to create simple HTML5 animations in responsive design easily
https://github.com/intersel/ifsmanimation

Last synced: 11 months ago
JSON representation

iFSMAnimation allows to create simple HTML5 animations in responsive design easily

Awesome Lists containing this project

README

          

iFSMAnimation
=============

Create elegant HTML5 animations in responsive design easily and quickly, with only one line of javascript code!

You describe the DOM objects that you want to animate, attached them to the animation machine, and let's animate!

To use it, have a look on the examples provided...

What is iFSMAnimation ?
=======================

iFSMAnimation is javascript library that allows to create animations from an html description.

Demos
=====

* http://www.macofi.fr/en/approach/
* https://www.intersel.fr/projects/franceurbaine/
* https://www.intersel.fr/projects/voeux2017/
* https://www.intersel.fr/en/other-pages/github/ifsm-animation-jquery-plugin.html - demos of the "examples" directory

Getting started
===============

Mainly, you need to create:
* a HTML 'section' (or whatever) that will define where is defined the animation and HTML 'articles' to define the different objects that must be animated.
* at the end, add a little script to start the animation...
* that's it! You've got an animation that is RESPONSIVE ! Without having to know how to write javascript code lines...

First Example
=============

The following example is a full animation that displays four pictures where different animations are applied. You could use this example as a starter template...

```html






article {opacity:0;}



















$(document).ready(function() {
//initialize and start the general animation
$('#animation-objects').iFSMAnimation();
});

```

General process
===============

An animation is defined by a main animation object attached to a container such a 'section'.

Within the container, you define the different animated objects attached/described by a subcontainer that is by default an 'article'.

Take care to **give an id to each object you will animate**.

The animation starts by calling each animated objects using the 'data-enter-animation' and just after 'data-animation' attributes to animate them.

When all objects were animated, the animation applies the 'data-exit-animation' definition of every animated objects to ending their animations, and then loops back.

Attributes on the main container
===============================
data-delay-before-restart
-------------------------
The 'data-delay-before-restart' attribute allows to define the delay before the animation restarts.

Example:
```html

```

data-box-responsive
-------------------
Boolean, if 'true', the animation will be 'responsive'.
Limitations known with using 'specialAnimate'.

Example:
```html

```

data-box-size-reference
-----------------------

"BoxWidth,BoxHeight" give the used dimensions as reference for the position of the animated objects. Useful in Responsive mode.

Example:
```html

```

data-keep-height-visible
------------------------
Boolean, if 'true', the width and height will be fixed in order that the animation is fully shown on the window display.
Example:
```html

```

data-div-class
--------------
Actually, a 'div' embeds the animation. It is possible to define the class that should be used on this div.

Example:
```html

```

data-loader-class
-----------------

A loader may be set during initialization.

To display a loader, just indicate the class to use with the data-loader-class attribute.

Example:
```html

```

Attributes on a sub container
=============================

data-enter-animation / data-animation / data-exit-animation
-----------------------------------------------------------

These attributes define the animation of the object.

The available animation are:
* dummy - non animation
* animate - animate article from current position or startposition to destination
* duration
* destination-left
* destination-top
* startposition-left - optional
* startposition-top - optional
* easing function - see http://easings.net/fr - optional
* display - display article (opacity set to 1) with animation from current position or startposition to destination
* duration
* destination-left
* destination-top
* startposition-left - optional
* startposition-top - optional
* easing function - see http://easings.net/fr - optional
* smoothHide - display article (opacity set to 0) with animation from current position or startposition to destination
* duration
* destination-left
* destination-top
* startposition-left - optional
* startposition-top - optional
* easing function - see http://easings.net/fr - optional
* rotate - rotate article
* duration
* angle
* loop - loop animation
* duration
* destination-left
* destination-top
* startposition-left - optional
* startposition-top - optional
* loops number - optional default:infinite - give the number of loops
* loop back delay - optional default: duration - give the delay to go to the initial position
* specialAnimate, specialAnimateNoWait
* duration
* animation description object as in jQuery. ex: {left: 20;top:100;width:300}
* void
* void
* void
* easing function - see http://easings.net/fr - optional
* animateNoWait - same as animate but does not wait the end of animation to start the next animation
* displayNoWait - same as display but does not wait the end of animation to start the next animation
* smoothHideNoWait - same as smoothHide but does not wait the end of animation to start the next animation
* rotateNoWait - same as rotate but does not wait the end of animation to start the next animation

Start the animation with javascript
===================================
To start the animation, you will need to add this script:
```javascript

$(document).ready(function() {
//initialize and start the general animation
$('section').iFSMAnimation();
)};

```

You can define some options:
animationSequence
-----------------
array, defines the order of animation of the objects. By default, the order is the one found in the DOM.

animatedObjectDefinition
------------------------
string, gives the HTML tag to find the animated objects (in css/jquery format).

examples:
---------
```javascript
var myAnimationSequence=['#myAnimObj2','#myAnimObj1'];
$('#animation-objects').iFSMAnimation({animationSequence:myAnimationSequence})
$('#animation2').iFSMAnimation({animatedObjectDefinition:'div',debug:true});
```

CSS
===

In order to have the animation playing correctly, you can use the following css as a start:

```css
body {
margin : 0px;
padding : 0px;
text-align : center;
}
/*for the div that embeds your animation section, will center it*/
#animation, .animation {
margin : 0 20% 30px 20%;
}
/*for the main animation section container, let's have a background*/
#animation-objects,.animated_section {
background-color: #1c3970;
}
/*for the animated objects (here, all objects will start as hidden at beginning - opacity=0)*/
section#animation-objects article {
opacity : 0;
}
```

Examples
========

The 'examples' folder gives you some examples on how to animate your DOM objects with iFSMAnimation...

LIBRARY DEPENDENCIES
====================
To work properly, you need to include the following javascript library:
* jQuery (>= 3.2) ``
* [iFSM by intersel](https://github.com/intersel/iFSM/)
* this library manages finite state machines and needs these libraries:
* doTimeout by ["Cowboy" Ben Alman](http://benalman.com/projects/jquery-dotimeout-plugin/)
* this library brings some very usefull feature on the usual javascript setTimeout function like Debouncing, Delays & Polling Loops, Hover Intent...
* ``
* attrchange by Selvakumar Arumugam](http://meetselva.github.io/attrchange/)
* a simple jQuery function to bind a listener function to any HTML element on attribute change
* ``
* [waitForImages](http://github.com/alexanderdickson/waitForImages/) by Alexander Dickson, in order to garantee that all images of the animation are downloaded and ready. This library is automatically loaded by iFSMAnimation.
* [jQuery UI](http://api.jqueryui.com/easings/) may be used to apply some effect on the animated objects as swing, easing, ...
* [jquery.path](https://github.com/weepy/jquery.path) may be used to defined arc and bezier for the path of animated objects.
* [FitText.js](http://fittextjs.com/) may be used to have 'responsive' texts

If you need to do some specific animations, these libraries may be useful:
* [jquery.path](https://github.com/weepy/jquery.path) - allows to animate objects following a path as an arc or a curve

FAQ
===

* my objects don't seem to be correctly positionned on the Y axe.
* Did you correctly set the "``" at the beginning of your file? without it, strange behaviour occurs!
* iFSMAnimation loads all its jquery libraries... but they are still loaded...
* you can empty the list of the libraries to load using the option 'ANIMATION_NEEDED_SCRIPTS':

```javascript
$('#myAnimation').iFSMAnimation({
ANIMATION_NEEDED_SCRIPTS:[]
});
```

Still some questions?
=====================
If you have questions or unsolved problems, you can have a look on the our [FAQs](https://github.com/intersel/iFSMAnimation/wiki)
or leave a message on the [Issue board](https://github.com/intersel/iFSMAnimation/issues).

Contact
=======
If you have any ideas, feedback, requests or bug reports, you can reach me at github@intersel.org,
or via my website: http://www.intersel.fr