2.1.4 • Published 1 year ago

@soatra/any v2.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Any

Any is a React component library used to create animating components with the help of Tailwind CSS.

Main updates in this version: 1. breakpoints: set breakpoints for duration, delay and easing. 2. after: move to next state while current state is animating. 3. on: handle at a specific point within the animation.

Usage

Default:

import Any from '@soatra/any';
import { Easings } from '@soatra/any/static';

const MyComponent = () => {
    return (
        <>
            <Any
                from="opacity-0"
                to={[
                    {
                        state: 'opacity-100',
                        duration: 1000,
                        easing: Easings.Linear
                    },
                ]}>
                <p>Animation</p>
            </Any>
        </>
    );
}

export default MyComponent;

Using start:

...
import { useState } from 'react';

const MyComponent = () => {
    const [start, setStart] = useState(false);

    return (
        <>
            <Any
                ...
                start={start}
                onStart={() => setStart(true)}>
                ...
            </Any>
        </>
    );
}

...

Loop:

...
    <Any
        ...
        start={start}
        onStart={() => setStart(true)}
        onEnd={() => setStart(false)}>
        ...
    </Any>
...

Multiple to states

...
    <Any
        ...
        to={[
            {
                state: 'opacity-50',
                duration: 1000,
                easing: Easings.Linear
            },
            {
                state: 'opacity-100',
                duration: 1000,
                easing: Easings.Linear
            },
        ]}
        ...>
        ...
    </Any>
...

Properties

-- from:

Type: string

is used to set initial state.

-- to:

Type: To[]

To:\ state: string\ duration: number | DurationValueBreakpoints\ easing: Easing | EasingValueBreakpoints\ delay: number | DelayValueBreakpoints | undefined\ start: boolean | undefined\ after: number | undefined\ on: On | On[] | undefined\ onEnd: (() => void) | undefined

is used to set flow-to states.

-- start:

Type: boolean | undefined

is used to start animation.

-- as:

Type: string | undefined

is used to set tag name for the element.

-- instant:

Type: boolean | undefined

is used to start animation instantly.

-- animatedProperties:

Type: string[] | undefined

is used to set animation properties.

-- mergeConfig:

Type: TailwindMergeType | undefined

is used to set tailwind merging configuration.

-- breakpoints:

Type: Breakpoints | undefined

is used to set window screen size breakpoints.

-- onStart:

Type: (() => void) | undefined

is used to handle when animation is starting.

-- onEnd:

Type: (() => void) | undefined

is used to handle when animation is ending.

-- onEnter:

Type: (() => void) | undefined

is used to handle when element enters the screen.

-- onLeave:

Type: (() => void) | undefined

is used to handle when element leaves the screen.

License

MIT

2.1.4

1 year ago

2.1.3

1 year ago

2.1.2

1 year ago

2.1.1

1 year ago

2.1.0

1 year ago

2.0.3

1 year ago

2.0.4

1 year ago

2.0.2

1 year ago

1.1.2

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago

0.1.1

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago