Skip to content
This repository was archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
✨ add ability to disable Modal animations
Browse files Browse the repository at this point in the history
  • Loading branch information
justinanastos committed Nov 21, 2019
1 parent 2c0900d commit a5f5180
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as typography from "../typography";
import { colors } from "../colors";
import * as CSS from "csstype";
import classnames from "classnames";
import { useSpaceKitProvider } from "../SpaceKitProvider";

interface Props {
/**
Expand Down Expand Up @@ -124,6 +125,8 @@ export const Modal: React.FC<Props> = ({
primaryAction,
secondaryAction,
}) => {
const { disableAnimations } = useSpaceKitProvider();

useEffect(() => {
function handleKeyDown(event: KeyboardEvent) {
if (event.code === "Escape" && onClose) {
Expand Down Expand Up @@ -154,7 +157,7 @@ export const Modal: React.FC<Props> = ({
children: (
<motion.div
animate={{ opacity: 1, scale: 1 }}
initial={{ opacity: 0, scale: 0.9 }}
initial={disableAnimations ? false : { opacity: 0, scale: 0.9 }}
transition={{
scale: {
type: "spring",
Expand Down

0 comments on commit a5f5180

Please sign in to comment.