GithubHelp home page GithubHelp logo

mrosata / js-animation-easing Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 156 KB

JS animation queue with easing functions. Uses quadratic equations to calculate animation positions that ease in or out

License: MIT License

JavaScript 100.00%

js-animation-easing's Introduction

js-animation-easing

Vanilla JS with a little Easing!

This is just a fun project I whipped up. It's a JavaScript class that can manage animating multiple elements around the screen, all with different animation times and 3 different easing options, linear, ease-in and ease-out. The easing functions make use of quadratic equation variances. It is called similar to the way one would call a jQuery animation function. Just get a reference to the HTMLElement , and do like below.

/**
 * This example, grabs 3 absolute positioned elements
 * then animates them at the same time,
 * but with different timing functions
 */
someElm = document.getElementById('someElement');
anotherElm = document.getElementById('two');
lastElm = document.getElementById('three');

// Regular linear animation
anime.animate(someElm, {'left':800,'top':300}, 5000, 'linear');
// Animation Ease Out
anime.animate(anotherElm, {'left':800,'top':200}, 5000, 'easeOut');
// Animation Ease In
anime.animate(lastElm, {'left':800,'top':100}, 5000, 'easeIn');

Documention

Note: The documentation inside the file labels extensions on the prototype object as private and public. This is merely post suggestive documentation, as there is no actual attempt at private implementation of any of the methods or properties. This code is merely an example of how semi-complex animations can be achieved with vanilla JavaScript. The actual structure of the class could be redesigned, I'm actually not too partial to building a class from the ground up directly off of its prototype, but that's what fun projects are for, fun!

Created by Michael Rosata

email @ [email protected]

site @ http://stayshine.com

js-animation-easing's People

Contributors

mrosata avatar

Stargazers

Joe Graham avatar

Watchers

James Cloos 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.