useModal

useModal is a custom react hook that gives you access to the modal context that allows you to operate on your scene. And when called it returns the following props:

openModal, closeModal, effects, types

openModal

The openModal handler accepts a modal type and a configs object:

type

The type of modal you want to open

configs

configdefinitiondefault
effectthe effect type you want to apply or custom effectPOP_UP
timeoutthe modal closes automaticaly after the timeout0
noOverlaydisable overlayfalse
springenable spring motionfalse
speedhow fast the modal opens and closes in secondseffect default duration
openSpeedhow fast the modal opens in secondseffect default duration
closeSpeedhow fast the modal closes in secondseffect default duration
fadewhether overlay should fade or notfalse
dataanything passed to data in going to be available in the opned modalnull
scrollwhether scoll is blocked after a modal is opened or notfalse
import React from "react";
import { useModal } from "@bigfan/modal";
export default function Btn() {
const {
openModal,
types: { NOTIFICATION },
effects: { SLIDE_LEFT },
} = useModal();
return (
<button
onClick={() =>
openModal(NOTIFICATION, {
effect: SLIDE_LEFT, // effect type
timeout: 5000, // closes after 5 seconds
noOverlay: true, // disabled overlay
spring: true, // enables spring motion
scroll: true, // allow scroll¸
data: { status: "😁" }, // passes smiley face to NOTIFICATION modal
})
}
>
OPEN
</button>
);
}

closeModal

closes any open modal.

import React from "react";
import { useModal } from "@bigfan/modal";
export default function Btn() {
const { closeModal } = useModal();
return <button onClick={() => closeModal()}>CLOSE</button>;
}

effects

types of effects avaliable

effects types
POP_UP
FADE
SLIDE_LEFT
SLIDE_RIGHT
SLIDE_UP
SLIDE_DOWN
FLIP_X
FLIP_Y
ROTATE

types

all modal types user passed to the <Provider> component.