This is a react hook for adding transition between an element on your page and an element in modal.
npm install use-modal-transition
npm i use-modal-transition
`
Quick start
1) Import the “useModalTransition” hook:
`javascript
import useModalTransition from "use-modal-transition";
`
2) Assign refs to the elements you want to animate.
`javascript
const firstElemRef = useRef(null);
const modalElemRef = useRef(null);
`
3) Create a state for the modal
`javascript
const [isOpen, setIsOpen] = useState(false);
`
4) Call the hook and pass the references and modal state
`javascript
useModalTransition({
modalOpened: isOpen,
firstElemRef,
modalElemRef,
});
`
5) Change the state onClick to start the animation.
`javascript
return (
<>
onClick={() => {
setIsOpen(false);
}}
ref={modalElemRef}>