Adjust the size of grid items when the user scrolls in a React

I am trying to implement an animation on my grid items where they shrink and expand as the user scrolls, similar to the effect seen on this website . So far, I have made no progress on this. Can anyone provide me with a hint, suggest a package that can help achieve this, or guide me on how to approach implementing this animation?

This is how my list appears:

 {projects?.map((projectData) => {
            const project = tData(projectData)
            const slug = toKebabCase(
                `${projectData.en?.client}-${projectData.en?.project}`
            )
            return  (
                <div
                    key={projectData.id}
                    className="projects-grid-item"
                    style={{
                        backgroundImage: `url(${project?.mainImage})`,
                    }}
                >
                    <div className="project-content-wrapper">
                        <div className="nox-h-4">
                            <Link href={`${PROJECTS_ROUTE}/${slug}`}>
                                <a>
                                    {project?.client} - {project?.project}
                                </a>
                            </Link>
                        </div>
                        <div className="additional-info-wrapper nox-body-1">
                            <div className="services">
                                {project?.services}
                            </div>
                            <div>{project?.year}</div>
                        </div>
                    </div>
                </div>
            )}

Answer №1

One way to start exploring is by delving into the capabilities of the Intersection Observer API, which offers a means to monitor elements within the visible portion of the screen.

Another avenue to consider is utilizing an observer instance to dynamically alter classes of elements and initiate the desired transitions you wish to incorporate.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Stop asynchronous API request in useEffect when component is unmounted

Is there a way to cancel an API call when a component unmounts, especially if it's made within a useEffect hook? useEffect(() => { const callAPI = async (): Promise<void> => { try { // ... make API call here } cat ...

Issues with Bootstrap's navbar-toggleable-sm functionality not functioning properly

Just started learning Bootstrap and following a tutorial on Lynda.com about customizing the navbar. However, despite following the tutorial step by step, my navbar is not behaving as expected - it's stacking vertically on all device sizes instead of j ...

Understanding the significance of "this" within node.js modules and functions

Upon using the require method, a JavaScript file is loaded. The code snippet demonstrates an interesting scenario where this behaves differently within different parts of the script. // loaded by require() var a = this; // "this" here refers to an empty ...

Employing absolute picture placement

I have a collection of clipped images, each with an absolute position: <img style='position:absolute;clip(xpx xpx xpx xpx);'/> <img style='position:absolute;clip(xpx xpx xpx xpx);'/> <img style='position:absolute;cl ...

Exploring JSON Data in Node-Red

Currently utilizing Node-Red for the purpose of counting individuals by implementing a flow that can successfully detect faces using visual recognition node. Presented below is the output from the Visual Recognition node taken directly from the Debug windo ...

Replica of Spotify - Bottom Section - HTML and CSS Styling

I have been attempting to replicate the Spotify interface using only HTML and CSS. While I have successfully created the player section, I am struggling to center the player and incorporate the other two details as shown in the attached images. The 'G ...

Ways to ensure a <div> element adjusts its height based on inner content dimensions

When using buttons in a chatbot that have text which changes based on selected options, I've encountered an issue where the text length sometimes exceeds the button's space. I'm looking for a way to make the containing div automatically adj ...

Incorporate HTML output into a React component using Typescript

I am trying to create a class in React using Typescript that includes a method with HTML output. However, I keep encountering an error regarding the output type of the function. interface StateProps { page: string, } class App extends React.Component< ...

Misplaced Bootstrap 4 tooltip causing alignment issues

Hello, I've encountered an issue while using Bootstrap 4 and have compiled the CSS from the Sass files using Ruby Sass 3.7.4. Although I removed certain parts of the Sass, I don't believe there are any dependencies affecting how Tooltips functio ...

The React application running in a Docker container is unable to establish communication with the Django application also running

After setting up a Django app and a React app to run locally on https://localhost:8000 with self-signed certificates, everything works smoothly when running them in a terminal. However, I encountered an issue when trying to run both apps from Docker Deskto ...

Utilizing ES6 Proxy leads to the occurrence of an error message stating "this is not a function" whenever a function call

As I ventured into the depths of ES6 Proxies, attempting to be a crafty developer, I found myself entangled in their complexities. My goal was to intercept any get or set operation on a property from a class I had written and ensure that they were stored e ...

Why isn't setInterval set to a duration of one thousand milliseconds?

While trying to use some code from w3schools, I noticed that the setInterval in the example is set to 5 instead of 5000. Shouldn't it be in milliseconds? If not, how can I speed up this animation? When I try reducing it to decimals like 0.01, the anim ...

Updating the names of keys within an object that includes nested child objects

I am looking to update the keys in an object that contains nested objects with similar structures. Initially, my object looks like this: objs = { "one":{ "title":"bla", "amount":5, "children":[ { "title":"bla", ...

Browser local storage protection

Utilizing local storage to preserve specific data for my website has been beneficial. Each necessary object is stored so that users can access them on their browser (in chrome: Resource -> Local Storage). My objective now is to make these objects unrea ...

I am looking for guidance on removing the bottom line from the ionic 4 segment indicator. Any advice or tips on

.segment-button-indicator { -ms-flex-item-align: end; align-self: flex-end; width: 100%; height: 2px; background-color: var(--indicator-color); opacity: 1; } I am a beginner in hybrid app development and ...

Can you identify the target of the term "this" in the upcoming JavaScript code?

DISCLAIMER: I am inquiring about a specific instance of this, not its general purpose. Please refrain from quick Google responses or copied answers (: The code snippet below demonstrates JavaScript/jQuery: var req = {}; function getData() { var from ...

I am facing an issue with the Tailwind Flowbite Datepicker dropdown UI when running "npm run prod" for minification. The class is not being added during minification on the npm

I have successfully integrated a Laravel project with Tailwind CSS. I have also implemented the Flowbite Datepicker using a CDN to include the necessary JavaScript. Initially, everything was working fine and the date-picker was displaying correctly. Howev ...

Angular.js fails to load successfully every other time

My angular application is running into some issues with bower. At times, when I start up the server, I encounter the following error: Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to: Error: [$injector:modulerr] Failed to in ...

Using PHP, retrieve the innerHTML value from a post method

I am trying to retrieve the innerHTML value of a label element within a form using post method and display it on another PHP page. So far, I have only been successful with textboxes, like in a login form. Any suggestions on how to achieve this? <div ...

Showing the SQL table data output

Attempting to present a new table based on the SQL query result. Below is the initial table code shown when the user first loads the page. TABLE: <form action="walkthroughs.php" method="POST"> Platform: <input type="text" name="platform" ...