diff --git a/packages/core/src/components/SlideTransition/SlideTransition.module.scss b/packages/core/src/components/SlideTransition/SlideTransition.module.scss index 06e7721991..7a0e46db1f 100644 --- a/packages/core/src/components/SlideTransition/SlideTransition.module.scss +++ b/packages/core/src/components/SlideTransition/SlideTransition.module.scss @@ -1,5 +1,4 @@ .slide { position: absolute; width: 100%; - height: 100%; } diff --git a/packages/core/src/components/SlideTransition/SlideTransition.tsx b/packages/core/src/components/SlideTransition/SlideTransition.tsx index 16ce32c84a..990073a8dc 100644 --- a/packages/core/src/components/SlideTransition/SlideTransition.tsx +++ b/packages/core/src/components/SlideTransition/SlideTransition.tsx @@ -6,7 +6,7 @@ import { SlideTransitionProps } from "./SlideTransition.types"; import styles from "./SlideTransition.module.scss"; const SlideTransition = forwardRef( - ({ direction, children, className }: SlideTransitionProps, ref: React.ForwardedRef) => { + ({ direction, style, children, className }: SlideTransitionProps, ref: React.ForwardedRef) => { return ( {children} diff --git a/packages/core/src/components/SlideTransition/SlideTransition.types.ts b/packages/core/src/components/SlideTransition/SlideTransition.types.ts index 77e23583bb..419f893f05 100644 --- a/packages/core/src/components/SlideTransition/SlideTransition.types.ts +++ b/packages/core/src/components/SlideTransition/SlideTransition.types.ts @@ -3,6 +3,7 @@ import { VibeComponentProps } from "../../types"; export interface SlideTransitionProps extends VibeComponentProps { direction: SlideDirection; + style?: React.CSSProperties; children: React.ReactNode; } diff --git a/packages/core/src/components/SlideTransition/utils/animationVariants.ts b/packages/core/src/components/SlideTransition/utils/animationVariants.ts index 3719def6bf..79ce19f9ab 100644 --- a/packages/core/src/components/SlideTransition/utils/animationVariants.ts +++ b/packages/core/src/components/SlideTransition/utils/animationVariants.ts @@ -2,17 +2,20 @@ import { SlideDirection } from "../SlideTransition.types"; export const slideAnimationVariants = { initial: (direction: SlideDirection) => ({ - x: direction === "forward" ? "10%" : "-10%" + x: direction === "forward" ? "10%" : "-10%", + opacity: 0 }), enter: { - x: 0 + x: 0, + opacity: 1 }, exit: (direction: SlideDirection) => ({ - x: direction === "forward" ? "-100%" : "100%" + x: direction === "forward" ? "-10%" : "10%", + opacity: 0 }) }; export const slideAnimationTransition = { - duration: 0.2, + duration: 0.1, ease: [0.0, 0.0, 0.4, 1.0] }; diff --git a/packages/core/src/components/TransitionView/TransitionView.tsx b/packages/core/src/components/TransitionView/TransitionView.tsx index 2948a05f72..8530152fc8 100644 --- a/packages/core/src/components/TransitionView/TransitionView.tsx +++ b/packages/core/src/components/TransitionView/TransitionView.tsx @@ -1,4 +1,4 @@ -import React, { forwardRef } from "react"; +import React, { forwardRef, useEffect, useRef, useState } from "react"; import cx from "classnames"; import { AnimatePresence } from "framer-motion"; import { TransitionViewProps } from "./TransitionView.types"; @@ -9,18 +9,34 @@ import SlideTransition from "../SlideTransition/SlideTransition"; const TransitionView = forwardRef( ( - { activeStep, direction, id, className, "data-testid": dataTestId, children }: TransitionViewProps, + { activeStep, direction, height, id, className, "data-testid": dataTestId, children }: TransitionViewProps, ref: React.ForwardedRef ) => { + const slideTransitionRef = useRef(null); + const [contentHeight, setContentHeight] = useState(height); + const slideTransitionHeight = height || contentHeight > 0 ? "100%" : "auto"; + + useEffect(() => { + if (!slideTransitionRef.current) return; + setContentHeight(slideTransitionRef.current.scrollHeight); + }, [height, slideTransitionRef]); + return (
- + {children[activeStep]} diff --git a/packages/core/src/components/TransitionView/TransitionView.types.ts b/packages/core/src/components/TransitionView/TransitionView.types.ts index 6dba5251e4..abc6c456d8 100644 --- a/packages/core/src/components/TransitionView/TransitionView.types.ts +++ b/packages/core/src/components/TransitionView/TransitionView.types.ts @@ -5,6 +5,7 @@ import { SlideDirection } from "../SlideTransition/SlideTransition.types"; export interface TransitionViewProps extends VibeComponentProps { activeStep: number; direction: TransitionDirection; + height?: number; children: React.ReactNode[]; }