From c2f133cd3642824ed7eea2896a45e034bef6d450 Mon Sep 17 00:00:00 2001 From: captain-Akshay Date: Tue, 19 Dec 2023 02:58:11 +0530 Subject: [PATCH] made it reusable and only for one collaborator component Signed-off-by: captain-Akshay --- src/components/Features/index.js | 91 +++++++++++--------- src/sections/Home/FeaturesContainer/index.js | 3 +- 2 files changed, 49 insertions(+), 45 deletions(-) diff --git a/src/components/Features/index.js b/src/components/Features/index.js index 0ab1f3c88562..d94a30a5ec10 100644 --- a/src/components/Features/index.js +++ b/src/components/Features/index.js @@ -22,54 +22,54 @@ const Features = (props) => { return persons[index]; } useEffect(() => { - const container = containerRef.current; + if (props.cursor !== undefined) { + const container = containerRef.current; - const moveRandomly = (element) => { - const rect = container.getBoundingClientRect(); - const maxX = rect.width; - const maxY = rect.height; - console.log(maxX, maxY, "here"); - const randomX = Math.floor(Math.random() * maxX); - const halfMaxY = maxY / 2; - const randomY = Math.floor(Math.random() * (maxY + 1)) - halfMaxY; + const moveRandomly = (element) => { + const rect = container.getBoundingClientRect(); + const maxX = rect.width; + const maxY = rect.height; + const randomX = Math.floor(Math.random() * maxX); + const halfMaxY = maxY / 2; + const randomY = Math.floor(Math.random() * (maxY + 1)) - halfMaxY; - element.style.transition = "transform 3s ease"; - element.style.transform = `translate(${randomX}px, ${randomY}px)`; + element.style.transition = "transform 3s ease"; + element.style.transform = `translate(${randomX}px, ${randomY}px)`; - setTimeout(() => { - element.style.transition = ""; - }, 3000); - }; + setTimeout(() => { + element.style.transition = ""; + }, 3000); + }; - const setInitialRandomPosition = (element) => { - const rect = container.getBoundingClientRect(); - const maxX = rect.width - element.clientWidth; - const maxY = rect.height - element.clientHeight; - const randomX = Math.floor(Math.random() * maxX); - const randomY = Math.floor(Math.random() * maxY); + const setInitialRandomPosition = (element) => { + const rect = container.getBoundingClientRect(); + const maxX = rect.width - element.clientWidth; + const maxY = rect.height - element.clientHeight; + const randomX = Math.floor(Math.random() * maxX); + const randomY = Math.floor(Math.random() * maxY); - element.style.transform = `translate(${randomX}px, ${randomY}px)`; - }; + element.style.transform = `translate(${randomX}px, ${randomY}px)`; + }; - const person1Element = container.querySelector(".person1"); - const person2Element = container.querySelector(".person2"); + const person1Element = container.querySelector(".person1"); + const person2Element = container.querySelector(".person2"); + setInitialRandomPosition(person1Element); + setInitialRandomPosition(person2Element); - setInitialRandomPosition(person1Element); - setInitialRandomPosition(person2Element); + const movePersonsRandomly = () => { + moveRandomly(person1Element); + setTimeout(() => { + moveRandomly(person2Element); + }, 3000); + }; - const movePersonsRandomly = () => { - moveRandomly(person1Element); - setTimeout(() => { - moveRandomly(person2Element); - }, 3000); - }; + movePersonsRandomly(); - movePersonsRandomly(); + const intervalId = setInterval(movePersonsRandomly, 6000); - const intervalId = setInterval(movePersonsRandomly, 6000); - - return () => clearInterval(intervalId); - }, []); + return () => clearInterval(intervalId); + } + }, [props.cursor]); function mouseEnterEvent() { setWaveStart(true); setTimeout(() => { @@ -82,7 +82,6 @@ const Features = (props) => { const style = { cursor: props.show_custom_cursor ? `url(${cursor}), auto` : "", }; - return ( { onMouseEnter={mouseEnterEvent} onMouseLeave={mouseLeaveEvent} > - + {waveStart && ( { className="waveAnimation" /> )} - + - - + +

{props.title}

diff --git a/src/sections/Home/FeaturesContainer/index.js b/src/sections/Home/FeaturesContainer/index.js index e62d7e31d5f7..4ddb93827090 100644 --- a/src/sections/Home/FeaturesContainer/index.js +++ b/src/sections/Home/FeaturesContainer/index.js @@ -32,7 +32,7 @@ const FeaturesContainer = () => { redirectLink="/comments" desc="Real-time collaboration for cloud and cloud native designs with live-editing, instant feedback, deploy dry runs, and secure access controls." imgLink={isDark ? CommentingImageDark : CommentingImageLight} - index={0} + cursor={0} /> {/* Elevate teamwork with integrated communication channels, ensuring efficient and secure project success. */} { redirectLink="/whiteboard" desc="Crafting cloud-native symphonies: Our engineering diagramming tool is your conductor's baton, turning Kubernetes infrastructure into a canvas for freestyle orchestration." imgLink={isDark ? WhiteboardingImage : WhiteboardingImageLight} - index={1} />
{/* a suite of annotation and visualization tools, allowing users to draw, annotate, and collaborate in real-time on their cloud native designs. */}