1.1.1 • Published 1 year ago

animation-wrapper v1.1.1

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

Animation-Wrapper

A Wrapper that use web animation API to animate the children on mount and unmount and destroy itself after unmount

Contents

Installation

npm install animation-wrapper

Usage

import { AnimationWrapper } from "animation-wrapper";

const [show, setShow] = useState(false);
return (
  <>
    <button onClick={() => setShow((state) => !state)}>Click me</button>
    <AnimationWrapper
      show={show}
      options={{ duration: 1500 }}
      from={{ opacity: 0, transform: "translateY(-100px)" }}
      to={{ opacity: 1, transform: "translateY(0)" }}
    >
      <ChildComponent />
    </AnimationWrapper>
  </>
);

const ChildComponent = () => {
  const [text, setText] = useState("");
  return (
    <input
      aria-label="string"
      value={text}
      onChange={(e) => setText(e.target.value)}
    />
  );
};

API

PropertyTypeDefaultDescription
showboolean-flag used to show/hide the child
childrenReactNode-Element to be animated
fromKeyFrame{ opacity: 0 }starting position/state of animation when mounting
toKeyFrame{ opacity: 1 }ending position/state of animation when mounting
unmountAnimationArray{ opacity: 0 }, { opacity: 1 }animation that needed to occur when unmounting, If not passed, mount animation will be reversed. i.e starts with to prop and ends with from prop
optionsobject{ duration: 500, fill: "forwards" }configuration of animation
classNamestring""className can be passed to change the wrapper style like making inline
1.1.1

1 year ago

1.1.0

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago