JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q23192F
  • License ISC

Simple and effective animation Library

Package Exports

  • nefesh

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (nefesh) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Nefesh


Nefesh is a simple library that returns an animated value according to the easing choosen function.

Install

npm install -D nefesh

Usage

import Nefesh from "nefesh";

const nefesh = new Nefesh({

    element: '.element',
    values: {
        x: 100,
        y: {
            from: 300,
            to: 100
        }
    },
    easing: "easeInOutExpo",
    duration: 700,
    begin: function ( element, values ) { ... },
    complete: function ( element, values ) { ... },
    progress: function ( element, values ) { ... }

});

Properties

element

default: null

'.element' indentifier. It will just cross the code, but to animate it you need to make it inside the progress callback.

values

default: { value: { from: 0, to: 1 } }

Values is an Object with the following syntax:

values :{
    value: {
        from: 0,
        to: 1
    }
}

You must send the from to the to value. It will always return the default object named value with an animation from 0 to 1.

You can also send just like this:

values: {
    value: 100
}

Nefesh will presume that it's the to value.

Or you can just send

values: 100

It will be the to value.

If you want to animate different, send multiples objects inside values:

values: {
    x: 200,
    y: {
        from: 450,
        to: 20
    }
}

ATENTION

Nefesh only calculates number values, colors are not supported.

easing

default 'easeInOutExpo'

Easing function to animate the values.

'linear', 'bounce',

'easeInCubic', 'easeOutCubic', 'easeInOutCubic',

'easeInExpo', 'easeOutExpo', 'easeInOutExpo',

'easeInElastic', 'easeOutElastic',

'easeInBack', 'easeOutBack', 'easeInOutBack',

duration

default: 700

Duration must be set in miliseconds.

begin

default: null

This function is called when the animation is about to start.

begin: function ( element, values ) { ... },

progress

default: null

This function is called in every step of the animation. Here is where you should animate your elements according to the values object.

progress: function ( element, values ) { ... }

complete

default: null

This function is called when the animation ends.

complete: function ( element, values ) { ... },