Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix large layout shift #219

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions src/components/Animations/BounceInScroll.component.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,25 @@
"use client";

import { Variants, motion } from "framer-motion";

import { IAnimateBounceProps } from "./types/Animations.types";

const bounceVariants: Variants = {
offscreen: {
y: 30,
opacity: 0,
scale: 0.98,
},
onscreen: {
y: 0,
opacity: 1,
scale: 1,
transition: {
type: "spring",
bounce: 0.5,
duration: 1.5,
damping: 20,
stiffness: 100,
duration: 0.5,
},
},
};

/**
* Bounce in content when content becomes visible in viewport
* @function BounceInScroll
* @param {ReactNode} children - Children content to render
* @param {string} cssClass - CSS classes to apply to component
* @param {"some" | "all" | number} viewAmount - Amount of component needed to be visible before animating
* @returns {JSX.Element} - Rendered component
*/

const BounceInScroll = ({
children,
cssClass,
Expand All @@ -38,11 +29,11 @@ const BounceInScroll = ({
initial="offscreen"
whileInView="onscreen"
viewport={{ once: true, amount: viewAmount || 0.2 }}
className={cssClass}
className={`${cssClass} overflow-hidden`} // Added overflow-hidden
data-testid="bounceinscroll"
>
<motion.div variants={bounceVariants}>{children}</motion.div>
</motion.div>
);

export default BounceInScroll;
export default BounceInScroll;