0.0.9 • Published 6 years ago

dl-animate v0.0.9

Weekly downloads
11
License
ISC
Repository
github
Last release
6 years ago

Javascrupt library to control CSS transitions and animations

Idea

Often we need animate DOM elements, when it show, hide, insert or remove.

Animations only for javascript have long been outdated. Javascript should control the animation described in CSS.

This library control CSS animations with 3 classes for show element: -enter, -enter-active, -enter-active-to and 3 classes for hide element: -leave, -leave-active, -leave-active-to

Install

NPM + Babel

$ npm i dl-animate --save
import DLAnimate from 'dl-animate/dist/dl-animate-module';

let anyName = new DLAnimate();

Simple

<script src="https://unpkg.com/dl-animate"></script>

Usage samples on jsfiddle

You also can find this samples on https://github.com/dmitry-lavrik/dl-aniamte/tree/master/demos

DescriptionLink
Nice show/hide elementhttps://jsfiddle.net/88fg95w1/
Nice append/remove elementhttps://jsfiddle.net/eLhnzLL7/
Events callbackhttps://jsfiddle.net/n8r78jr4/
Hard durationhttps://jsfiddle.net/hcdcx51f/
Insert element before otherhttps://jsfiddle.net/4qnzL450/
Keyframes + animationhttps://jsfiddle.net/98a4aeee/
User classNameshttps://jsfiddle.net/3vn9j63n/
Start values in enter-leave classeshttps://jsfiddle.net/L74sb1nh/

Methods of DLAnimate instance

show(DOMElemenet, options)

Show element with animation only if element is hidden now.

hide(DOMElemenet, options)

Hide element with animation only if element is visible now.

insert(parentElemenet, newElement, options, insertBeforeElement = null)

Insert newElement to parentElemenet and animate after it.

If insertBeforeElement is null, newElement append in parentElemenet.

If insertBeforeElement is other child of parentElemenet, newElement will insert before insertBeforeElement.

remove(DOMElemenet, options)

Hide element with animation and then remove element from DOM.

Options

It's very important argument for all methods!

NameTypeDescriptionDefaultSample
nameStringstring for class names generationdl-nothing-doing-classhttps://jsfiddle.net/88fg95w1/
trackStringhow we control end of animation (transition, animation, none)transitionhttps://jsfiddle.net/98a4aeee/
durationNumberinteger number to stop animation when track is 'none'nullhttps://jsfiddle.net/hcdcx51f/
classNamesObjectobject with class names, which we use instead of auto generated{}https://jsfiddle.net/3vn9j63n/
beforeEnterFunctioncallback before element enterfunction(el){}https://jsfiddle.net/n8r78jr4/
afterEnterFunctioncallback when element was enteredfunction(el){}https://jsfiddle.net/n8r78jr4/
beforeLeaveFunctioncallback before element leavefunction(el){}https://jsfiddle.net/n8r78jr4/
afterLeaveFunctioncallback when element was leavedfunction(el){}https://jsfiddle.net/n8r78jr4/

A more detailed description in the creation process.

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago