Giter VIP home page Giter VIP logo

element-animation's Introduction

Social Card of element-animation

NPM Downloads NPM Github Code Size GitHub License

element-animation

What is this project for?

You can use this project to create congratulation confetti, snow or leaves falling from top to bottom or moved by mouse. Also elements insider your hole document can be moved by mouse movement. With this project you can create awesome effects on your website.

Start with a simple test file to see what the project can do without coding yourself. First you need to download the project and then go to the test folder and preview the bootstrap html file.

Live preview

View the test file live on GitHub Pages with clicking here.

Documentation

Get started

To start with the project element-animation you need to install via NPM and then import it.

npm i element-animation
import elementAnimation from element-animation

var elemAnim = new elementAnimation(
    container,
    props,
    options
)

container -> DOMElement (default: null)
props -> Array (default: [])
options -> Object (default: {})

Before we start to define the variables you need to know that you only need container and props when using the functions rain(), mousemove() and rainWithMousemove(). First we start with the container. Here you need to give a DOMElement for example a simple <div></div> container.

<div id="element-animation"></div>
const container = document.getElementById('element-animation')

Then you need to define props. There you give an array with the sources to the images like .jpg or .svg.

props = [
    'src_to_img',
    'src_to_img_1'
]

For the options you have the following possibilities. When a comment is behind a option it means that the option is only for a specific funtion.

options = {
    interval: 550,          // rain
    rotate: [-40, 40],
    size: [10, 15],
    duration: [5, 13],      // rain
    amount: [30, 40]        // mousemove
}

Now you need to call one of the given functions described down below to visially see the animation. Choose between rain(), mousemove(), rainWithMousemove() and a special function mousemoveElements().

Functions

All functions except mousemoveElements() need a container for the generated elements.

rain()

new elementAnimation(container, props, options).rain()

mousemove()

new elementAnimation(container, props, options).mousemove()

rainWithMousemove()

new elementAnimation(container, props, options).rainWithMousemove()

mousemoveElements()

data-p-element -> Defines that it is a element for movement
data-p-move -> Factor from 0 to unlimited (float with dots allowed)

<div data-ea-element data-ea-move="0.5">
    Example text or element here.
</div>

<div data-ea-element data-ea-move="0.8">
    Secound example text or element here.
</div>
new elementAnimation(container, props, options).mousemoveElements()

Helpers

reset()

Can be used to reset all prop actions. After a reset you can call another functions

const elemAnim = new elementAnimation(container, props, options).rain()

elemAnim.reset()
elemAnim.mousemove()

Changelog

Please see CHANGELOG for more information what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.

element-animation's People

Contributors

jersyfi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

schnehowebking

element-animation's Issues

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.