Giter Site home page Giter Site logo

animata's Introduction

Animata JS

Animata is a tiny JS (vanilla) to make use of CSS to create simple animation.

Usage

Import main.js file and use it like this:

var animata1 = new Animata({
    count: 6; // number of animation step
    wrapper: "#anim1", // element that wraps your animation
    duration: 1000, // duration for each step
    onTransition: [
        {
            elems: ["#block1"], 
            func: function(){
                 //... function to
                 // launch continuously.
                 // Animata execute that function
                 // on requestAnimationFrame
            }
        }
    ],
    steps: [
        {
            step: 4, // eg. to override step 4
            after: 3000, // step 4 will take 4s,
            actions: [
                func(){}, //... functions to launch at step 4
            ]
        }
    ]
})

animata1.start(); // => launch animation 

When "start" is launched, Animata will set "animata-step-N" class to the wrapper element where "N" is the number of current step. Each step is added, that means that wrapper element will have "animata-step-1 animata-step-2 animata-step-3" classes at step 3.

A new call to "start" removes the entire animata classes from the wrapper element, and animation will start again from step 1.

You can now create your CSS.

Example:

/* make div elements to be animated with nice transition */
#anim1 div {
    transition: 1s all linear; 
}

/* block to animate */
#anim1 .block1 {
    opacity: 0;
    background-color: #FFFFFF;
}

/* Step 1, reveal block and move it to 150px left */
#anim1.animata-step-1 .block1 {
    opacity: 1;
    margin-left: 150px;
}

/* Step 2, change background color */
#anim1.animata-step-2 .block1 {
    background-color: #AFAFAF
}

And associated HTML

<div id="#anim1">
    <div class="block1">The animated block</div>
</div>

And finally, the JS:

var animata = new Animata({
    count: 2;
    wrapper: "#anim1",
    actions: [
        {
            step: 1,
            func: function(){
                console.log("this is the step 1 !")
            }
        }
    ]
});
animata.start()

You can also use "next()" and "prev()" method to create a "player" and let user go step forward and backward.

animata's People

Contributors

metal3d 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.