0.4.3 • Published 2 years ago

anima-js v0.4.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Anima.js 🎞

Anima.js - SCSS/SASS Animation library. With Anima.js you can write compact code using the transitions and animations controlled from javascript.

Download

npm:

npm install anima-js --save

yarn:

yarn add anima-js

Usage

import useAnima from "anima-js";

const App = ({ isVisible }) => {
  const { anima } = useAnima();
  
  return (
    <anima.h1 className="title" state in={isVisible}>
      Hello world
    </anima.h1>
  )
}
.title {
  @include in {
    opacity: 1;
    transition: opacity .5s;
  }

  @include out {
    opacity: 0.5;
    transition: opacity .25s;
  }
}
@mixin in {
  &[class$="enter"] {
    @content;
  }
}

@mixin out {
  &[class$="exit"] {
    @content;
  }
}

@mixin animation-in($animation: 1s 0s both) {
  &[class$="enter"] {
    $name: anima-#{unique-id()};
    animation: #{$name} $animation;
    @keyframes #{$name} {
      @content;
    }
  }
}

@mixin animation-out($animation: 1s 0s both) {
  &[class$="exit"] {
    $name: anima-#{unique-id()};
    animation: #{$name} $animation;
    @keyframes #{$name} {
      @content;
    }
  }
}

Examples

Simple Transition

Switch Transition

Group Transition

Animated Button

Callbacks

A callback that will fire when an animation starts.

onAnimaStart: (in: boolean, node: HTMLElement) => void

A callback that will fire when an animation has finished.

onAnimaDone: (in: boolean, node: HTMLElement) => void

A callback that fires before an animation starts. If you want to use custom animation you need this method.

onAnimaTransition: (in: boolean, node: HTMLElement, done: Function) => void

Custom Components

Sometimes you need to use custom components.

const MyComponent = ({ children }) => (
  <h1>{children}<h1>
)

<anima.custom component={MyComponent}>
  Hello world
</anima.custom>
0.4.3

2 years ago

0.4.2

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.9

2 years ago

0.3.8

2 years ago

0.3.7

2 years ago

0.3.6

2 years ago

0.3.5

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.3.2-3

2 years ago

0.3.2-2

2 years ago

0.3.2-1

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.9-12

2 years ago

0.2.9-11

2 years ago

0.2.9-10

2 years ago

0.2.9-9

2 years ago

0.2.9-8

2 years ago

0.2.9-7

2 years ago

0.2.9-6

2 years ago

0.2.9-5

2 years ago

0.2.9-4

2 years ago

0.2.9-3

2 years ago

0.2.9-2

2 years ago

0.2.9-1

2 years ago

0.2.9

2 years ago

0.2.8

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.2

2 years ago

1.0.8

2 years ago