Coder Social home page Coder Social logo

magicbyt3 / anifx Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 22 KB

js library to animate anything you possibly can using web animations api with some extended functionality.

Home Page: https://magicbyt3.github.io/proxima/

License: Other

JavaScript 100.00%

anifx's Introduction

Anifx

with anifx you can animate almost everything on a webpage in the most easy way utilizing the web animation api.

Installation

with your favorite package manager:

npm i p13rnd-anifx

Usage

import { Fx } from 'p13rnd-anifx';

// animate node
const myFx = new Fx();
myFx.animateNode(node, options);

node

the dom node you want to animate

options

an object of options can be passed to the function. See all possible options below.

const animations = 'color: [#aa0033, #00aa33, red, orange, rgba(117, 117, 117, 0.9), randomColor, randomColor] | transform: [translateX(-50%), scale(2), rotate(45deg)]';

const options = {
  myFx.animateNode(node, {
    animationString: animations, 
    timing: {
      duration: 1500,
      easing: 'linear',
      fill: 'none',
      direction: 'normal',
      iterations: 1,
      delay: 0
    },
    split: false,
    clean: true,
    retain: false,
    delayBetweenLetters: 0
  });
}

easing

Add an easing function to your animation, linear, ease-in-out, cubic-bezier and more.
See all available Options
Default: 'linear'

duration

The duration of the animation in milliseconds (ms) Default: 1500

fill

Sets the animation fill mode to control css properties before and after the animation.
Learn more
Default: 'none'

direction

The direction of the animation. Used to play backwards (flip the animation cycle)
Learn more
Default: 'normal'

iterations

The number of times an animation should run. Use 0 to run infinite.
Default: 1

delay

The delay before an animation starts playing. Default: 0

fullNode

Wether to animate the entire node or it's single parts (letters). Does only work on nodes with text content.

delayBetween

The delay between each letter. Only works if fullNode is set to false.
Default: 0

clean

Decide if spans should continue to exist after the animation completes. Only works if fullNode is set to false. Default: true

retain

You can retain specific properties, for example retain="color, transform" would retain both css properties last value of the animation independent of fill. If not set the node will fall back to it's initial styles. Default: false

animations

The animations to run on the node or it's parts. The syntax is easy

property: [value1, value2, value3] | property2: [value4, value5, value6] | property3 ...

Example:

color: [#aa0033, #00aa33, red, orange, rgba(117, 117, 117, 0.9), randomColor, randomColor] | transform: [translateX(-50%), scale(2), rotate(45deg)] | padding: [3px, 6px, 9px]

hint: randomColor applies a random color
Default: ''

There's even more possible options when using anifx with X-Element and Astro.
You can see how it's been used here.

Contributing

Pull requests are welcome and discussions on further development and features are more than welcome.

License

MIT

anifx's People

Contributors

mrsuniverse avatar

Stargazers

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