Skip to content

Conversation

@nknaleena101
Copy link

@nknaleena101 nknaleena101 commented Dec 24, 2025

Summary by CodeRabbit

  • New Features

    • Added rich GSAP-powered animations across multiple pages: from/to tweens, timeline sequences with loop/yoyo, staggered group animations, scroll-synced animations, text reveal sequences, and a play/pause control for timeline playback; minor visual size and style adjustments to animated elements.
  • Chores

    • Added GSAP-related dependencies to enable the new animation features.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 24, 2025

📝 Walkthrough

Walkthrough

Adds gsap and @gsap/react to dependencies and integrates GSAP animations across several React pages, introducing mount-time tweens, a looping timeline with play/pause, staggered animations, and ScrollTrigger-driven scroll-synced tweens.

Changes

Cohort / File(s) Summary
Dependencies
package.json
Added gsap (^3.14.2) and @gsap/react (^2.1.2) to dependencies.
Simple tweens
src/pages/GsapFrom.jsx, src/pages/GsapFromTo.jsx, src/pages/GsapTo.jsx
Import useGSAP and gsap; mount-time tweens (gsap.from, gsap.fromTo, gsap.to) targeting #green-box, #red-box, #blue-box with 2s duration, infinite repeat, yoyo, and easing.
Timeline & controls
src/pages/GsapTimeline.jsx
Adds gsap.timeline({ repeat: -1, repeatDelay: 1, yoyo: true }), three sequential .to steps on #yellow-box (position, rotation, borderRadius, color), and a Play/Pause toggle; box size adjusted.
Stagger animations
src/pages/GsapStagger.jsx
Adds gsap.to stagger targeting .stagger-box (y movement, rotation, stagger timing, repeat/yoyo); UI boxes updated with a top-border style.
Scroll-triggered animations
src/pages/GsapScrollTrigger.jsx
Registers ScrollTrigger, creates a scroll container ref, and sets up per-child ScrollTrigger-driven tweens (x, rotation, borderRadius) with scrub: true and scroll-based start/end.
Text animation
src/pages/GsapText.jsx
Adds mount-time animations for #text (opacity/y) and .para elements (opacity/y stagger) to reveal content on mount.

Sequence Diagram(s)

sequenceDiagram
  participant C as React Component
  participant H as useGSAP Hook
  participant G as gsap
  participant S as ScrollTrigger (plugin)
  participant D as DOM Elements

  Note over C,H: Component mounts
  C->>H: call useGSAP(callback)
  H->>G: run callback -> create tween/timeline or register plugin
  alt timeline / simple tween / stagger
    G->>D: attach tween/timeline to targets (e.g., `#green-box`, .stagger-box)
    Note right of D: animations play (repeat/yoyo/controls)
  end
  alt scroll-triggered
    H->>G: register ScrollTrigger plugin
    G->>S: configure ScrollTrigger for each target
    S->>D: bind scroll-driven animations (scrub, start/end)
  end
  Note over G,D: animations execute and respond to controls/scroll
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through code with a whiskered grin,
I nudged the boxes, let the timelines spin,
Staggers twirl, scrolls align,
Play, pause, repeat — all in time,
A tiny hop, and animations begin 🎶

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'gsap basic functions' accurately describes the primary change—adding GSAP animation examples across multiple components using basic GSAP methods (to, from, fromTo, timeline, stagger, ScrollTrigger, and text animations).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/pages/GsapTimeline.jsx (1)

64-70: Consider adding button styling for consistency.

The Play/Pause button logic is correct, but it lacks styling classes. Adding Tailwind classes would improve consistency with the rest of the UI.

🔎 Suggested styling improvement
-      <button onClick={() => {
+      <button 
+        className="px-4 py-2 bg-blue-500 text-white rounded-lg hover:bg-blue-600 transition-colors"
+        onClick={() => {
-        if(timeLine.paused()) {
-          timeLine.play();
+        if(timelineRef.current?.paused()) {
+          timelineRef.current.play();
         } else {
-          timeLine.pause();
+          timelineRef.current.pause();
         }
       }}>Play/Pause</button>

Note: Also added optional chaining (?.) for safety when accessing the timeline ref.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5fa2cb5 and 660cc7f.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (5)
  • package.json
  • src/pages/GsapFrom.jsx
  • src/pages/GsapFromTo.jsx
  • src/pages/GsapTimeline.jsx
  • src/pages/GsapTo.jsx
🔇 Additional comments (5)
src/pages/GsapFrom.jsx (1)

1-14: LGTM! Clean GSAP implementation.

The gsap.from() animation is correctly implemented using the useGSAP hook with an empty dependency array to run once on mount. The animation properties are valid and will create a smooth looping animation.

src/pages/GsapFromTo.jsx (1)

1-19: LGTM! Correct fromTo implementation.

The gsap.fromTo() animation is properly implemented with distinct from and to states. The animation will smoothly transition the box from the starting state to the end state with looping.

src/pages/GsapTo.jsx (1)

1-14: LGTM! Solid gsap.to() implementation.

The gsap.to() animation is correctly implemented with proper hook usage. The combination of translation and rotation creates an engaging animation effect.

src/pages/GsapTimeline.jsx (1)

9-28: Animation sequence logic is correct.

The timeline animation sequence is well-structured with three distinct stages. Once the timeline creation issue is resolved, these animations will execute properly in sequence.

package.json (1)

13-14: No action required — GSAP dependencies are current and secure.

Both @gsap/react@2.1.2 and gsap@3.14.2 are the latest stable versions available on npm with no known security vulnerabilities. The caret version specifiers allow automatic patching within the current minor version.

Comment on lines +6 to +8
const timeLine = gsap.timeline({
repeat: -1, repeatDelay: 1, yoyo: true,
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical: Timeline recreated on every render causing memory leaks.

The timeline is created at the component's top level, which means it's recreated on every render. This causes:

  • Memory leaks from unreleased timeline instances
  • Unpredictable animation behavior
  • Play/Pause button referencing different timeline instances
🔎 Recommended fix using useRef

Import useRef and move the timeline creation inside useGSAP:

-import { useGSAP } from "@gsap/react";
+import { useGSAP } from "@gsap/react";
+import { useRef } from "react";
 import gsap from "gsap";
 
 const GsapTimeline = () => {
   // TODO: Implement the gsap timeline
-  const timeLine = gsap.timeline({
-    repeat: -1, repeatDelay: 1, yoyo: true,
-  });
+  const timelineRef = useRef();
+
   useGSAP(() => {
+    timelineRef.current = gsap.timeline({
+      repeat: -1, repeatDelay: 1, yoyo: true,
+    });
-    timeLine.to("#yellow-box", {
+    timelineRef.current.to("#yellow-box", {
       x: 200,
       rotation: 360,
       borderRadius: "100%",
       ease: 'power1.inOut',
       backgroundColor: "green"
     })
-    timeLine.to("#yellow-box", {
+    timelineRef.current.to("#yellow-box", {
       x: 0,
       y: 100,
       backgroundColor: "red",
       ease: "power1.inOut"
     })
-    timeLine.to('#yellow-box', {
+    timelineRef.current.to('#yellow-box', {
       x:200,
       ease: "power1.inOut",
       backgroundColor: "blue"
     })
   }, []);

And update the button to use the ref:

       <button onClick={() => {
-        if(timeLine.paused()) {
-          timeLine.play();
+        if(timelineRef.current.paused()) {
+          timelineRef.current.play();
         } else {
-          timeLine.pause();
+          timelineRef.current.pause();
         }
       }}>Play/Pause</button>
🤖 Prompt for AI Agents
In src/pages/GsapTimeline.jsx around lines 6 to 8: the gsap.timeline is created
at the component top level and thus recreated on every render; move timeline
creation into a stable ref inside your useGSAP hook (import useRef), e.g. create
a timelineRef = useRef(null) and initialize timelineRef.current only once (if
null) with gsap.timeline({ repeat: -1, repeatDelay: 1, yoyo: true }) inside an
effect or the hook initialization; update Play/Pause button handlers to call
timelineRef.current.play()/pause() (or toggle) instead of referencing the
transient variable; remove the top-level timeline declaration and add cleanup on
unmount (timelineRef.current.kill() or clear()) to prevent leaks.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/pages/GsapStagger.jsx (1)

52-58: Consider the necessity of the red top border.

Each stagger-box now includes border-t-4 border-t-red-500 styling. If this is purely for visual decoration, it looks fine. However, if it was added for debugging purposes, consider removing it.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 660cc7f and 2eea240.

📒 Files selected for processing (1)
  • src/pages/GsapStagger.jsx
🔇 Additional comments (2)
src/pages/GsapStagger.jsx (2)

1-2: LGTM!

The GSAP imports are correctly structured for React integration.


6-19: LGTM!

The stagger animation is correctly implemented with appropriate configuration. The useGSAP hook with an empty dependency array ensures the animation runs once on mount, and the stagger settings create a visually appealing sequential effect.

import gsap from "gsap";

const GsapStagger = () => {
// TODO: Implement the gsap.stagger() method
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Remove the obsolete TODO comment.

The stagger animation is now fully implemented, so the TODO comment should be removed.

🔎 Proposed fix
-  // TODO: Implement the gsap.stagger() method
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// TODO: Implement the gsap.stagger() method
🤖 Prompt for AI Agents
In src/pages/GsapStagger.jsx around line 5 the file contains an obsolete TODO
comment "// TODO: Implement the gsap.stagger() method"; remove that comment line
so the codebase no longer references an already-implemented task and keep the
file clean of outdated TODOs.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
src/pages/GsapScrollTrigger.jsx (3)

10-10: Remove the TODO comment.

The ScrollTrigger implementation is complete below, so this TODO comment should be removed.

🔎 Proposed fix
-  // TODO: Implement the gsap scroll trigger

21-22: Consider using consistent quote style.

The rest of the file uses double quotes for strings. For consistency, consider using double quotes here as well.

🔎 Proposed fix
-          start: 'bottom bottom',
-          end: 'top 20%',
+          start: "bottom bottom",
+          end: "top 20%",

80-80: Remove trailing whitespace.

This line contains only whitespace and should be removed for cleaner code.

🔎 Proposed fix
-   
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2eea240 and e55def2.

📒 Files selected for processing (1)
  • src/pages/GsapScrollTrigger.jsx
🔇 Additional comments (2)
src/pages/GsapScrollTrigger.jsx (2)

1-6: LGTM!

The imports and ScrollTrigger plugin registration are correctly implemented.


19-24: No action required. The ScrollTrigger configuration syntax is correct for GSAP 3.14.2. Both start: 'bottom bottom' and end: 'top 20%' follow valid GSAP ScrollTrigger syntax patterns where the format is "placeOnTrigger placeOnScroller" (e.g., "top center", "bottom 80%", "top 20%").

scrub: true,
},
ease: 'power1.inOut',
opacity: 100
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix incorrect opacity value.

The opacity property should be between 0 and 1, not 100. While this will be clamped to 1, it indicates incorrect usage and should be fixed.

🔎 Proposed fix
-        opacity: 100
+        opacity: 1
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
opacity: 100
opacity: 1
🤖 Prompt for AI Agents
In src/pages/GsapScrollTrigger.jsx around line 26, the style uses opacity: 100
which is invalid (opacity must be 0–1); change the value to the intended
fractional value (e.g., 1 for fully opaque or 0.0–0.99 for transparency) so the
property is correct and not relying on clamping.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/pages/GsapText.jsx (2)

7-10: Consider adding explicit duration for consistency.

While the animation is functional, it lacks an explicit duration property (defaulting to 0.5s). Adding duration would make the animation timing more explicit and maintainable.

🔎 Optional improvement
 gsap.to("#text", {
   opacity: 1,
   y: 0,
+  duration: 0.5,
+  ease: "power2.out",
 })

11-19: Minor formatting inconsistency.

Line 12 has a formatting issue: opacity:0 is missing a space after the colon. Additionally, consider adding an explicit duration property for clarity.

🔎 Optional improvements
 gsap.fromTo(".para", {
-  opacity:0,
+  opacity: 0,
   y: 60,
 }, {
   opacity: 1,
   y: 0,
+  duration: 0.5,
   delay: 0.5,
   stagger: 0.4,
 })
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e55def2 and 5bc3e3b.

📒 Files selected for processing (1)
  • src/pages/GsapText.jsx

import gsap from "gsap";

const GsapText = () => {
// TODO: Implement gsap text animation
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Remove outdated TODO comment.

The GSAP text animation has been implemented, so this TODO comment is no longer relevant and should be removed.

🔎 Proposed fix
-  // TODO: Implement gsap text animation
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// TODO: Implement gsap text animation
🤖 Prompt for AI Agents
In src/pages/GsapText.jsx around line 5, remove the outdated "// TODO: Implement
gsap text animation" comment because the animation has been implemented; simply
delete that line (and any leftover empty line if necessary) to keep the file
clean and up-to-date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant