Text reveal animation in Framer Motion is not functioning as expected

I'm having trouble locating the issue in my code, and the text reveal feature isn't working. Interestingly, a simple animation works fine, indicating that there's no problem with the import or library:


      import { motion } from "framer-motion";

      const banner = {
        animate: {
          transition: {
            delayChildren: 0.4,
            staggerChildren: 0.1,
          },
        },
      };

      const letterAni = {
        initial: { y: 400 },
        animate: {
          y: 0,
          transition: {
            ease: [0.6, 0.01, -0.05, 0.95],
            duration: 1,
          },
        },
      };

      const AnimatedLetters = ({ title }) => (
        <motion.span
          className="row-title"
          variants={banner}
          initial="initial"
          animate="animate"
        >
          {[...title].map((letter, i) => (
            <motion.span className="row-letter" variants={letterAni} key={i}>
              {letter}
            </motion.span>
          ))}
        </motion.span>
      );

      export default function TestFramer() {
        return (
          <div className="text-9xl">
            <AnimatedLetters title="title" />
          </div>
        );
      }
  

Answer №1

Animating the properties of x and y on inline elements (such as span) is not possible. To achieve this effect, you should use a block-level element (like div), or apply some styling to make your spans behave like block-level elements:

<motion.span 
    style={{display: "inline-block"}} 
    className="row-letter" 
    variants={letterAni} 
    key={I}
>
    {letter}
</motion.span>

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

What is the process for including a button in the navigation bar?

Just recently embarking on my Docusaurus journey, I am eager to customize the navbar by adding a Sign Up button (even though I understand it is primarily for documentation purposes). Despite my attempts to use swizzle to modify components, I have unfortu ...

The styling applied through the MUI TextField sx props does not take effect

Currently, I am attempting to customize a TextField component in a unique way using the sx prop: <TextField size="small" sx={{ padding: '1px 3px', fontSize: '0.875rem', lineHeight: '1.25 ...

Updating Auth.js to modify the Session interface

I recently started using Next.js 14 and decided to play around with Auth.js. I've encountered an issue where the Session interface is not being overridden as expected. auth.ts import NextAuth, {NextAuthConfig, Session, User} from "next-auth"; import ...

Utilizing the useEffect dependency array with a basic variable

Typically, I use values from the state/props to trigger useEffect and include them in the dependency array. I'm wondering if it's considered good practice to also include a simple variable (such as string or number) in the dependency array, or i ...

The challenges of utilizing breakpoints effectively within Tailwind CSS

So here's the issue. I've gone through various other queries related to this problem but haven't found a solution yet. Tailwind seems to be functioning well except for breakpoints. This is what I have in the head <meta name="viewpo ...

Is there a way to change the fill color of an SVG circle using Thymeleaf?

I am struggling to change the background color of a circle in an SVG image on my HTML page using Thymeleaf. I attempted to use inline style tags, but it resulted in the circle's background color turning black. <svg id="svg" height="50" width=" ...

NextJS is throwing an error when trying to access the value returned

I've been exploring next.js and am trying to implement useContext for managing global state. However, I'm encountering difficulty in passing the value from provider to child element as the returned value of language in header.js is coming up as u ...

Creating a new component when a click event occurs in React

Currently diving into the world of React while working on a project that involves mapbox-gl. I'm facing an issue where I can successfully log the coordinates and description to the console upon hover, but I can't seem to get the popup to display ...

You cannot include a body in a request using the GET/HEAD method when using APOLLO-CLIENT

Currently utilizing docker network and attempting to use apollo-client along with apollo-upload (createUploadLink) while also attempting to include the Bearer token in the headers. The error message that pops up is "Request with GET/HEAD method cannot have ...

Is there a way to trigger a function for both a left and middle click at the same time?

Check out this code snippet: $('a').on('click', function(){ myfunc($(this)); }); function myfunc(el){ console.log('Either left or middle click clicked on the link'); } a{ cursor: pointer; } <script src="https://aj ...

Using PHP Hover should apply CSS styles exclusively to the specified element

I have a piece of PHP code that displays cards. What I need: When a user hovers over the entire element, I want to make the title bolder, move the arrow to the left, and zoom in on the image of that particular hovered element. <div class="posti-class ...

Is there a way to dynamically alter the fill color of an SVG component using props along with tailwindcss styling?

Having a bit of trouble cracking this code puzzle. I've got a logo inside a component, but can't seem to pass the className fill options correctly. This is all happening in a NextJS environment with NextUI and tailwind css. const UserLogo = (prop ...

Steps for Implementing an Event Listener in JavaScript

While working on a page in Chrome, I encountered an issue where I wanted a modal to show up when a user clicked on an image. However, the functionality was not working as expected on my localhost. Upon further inspection, I believe there might be a problem ...

Challenges Arising from Cross-Origin Resource Sharing in Google Authentication

I've been incorporating Google Auth into my MERN stack web application. Unfortunately, I ran into an issue: When trying to connect to 'http://localhost:5000/api/v1/auth/google' from 'http://localhost:5173', the request was blocked ...

What is the easiest way to modify the color of a basic PNG image in a web browser?

While working on a website project, I encountered instructions for mouseover styles in the design that got me thinking: It's straightforward to achieve with javascript or css image swapping... but here's the catch. There will be multiple icon li ...

Position divs to align text beside icons

I am currently working on a Bootstrap popover to display various pieces of information, each containing an icon and some text. Additionally, I am incorporating twig into this project. Here is the HTML structure: <span class="fa fa-user instructor-con ...

Integrate actual credentials into S3Client using redux async thunk

My S3-like react application with redux is powered by AWS SDK v3 for JS. The client initialization in my auth.js file looks like this: auth.js export const s3Client = new S3Client({ region: 'default', credentials: { accessKeyId: 'te ...

Exploring a custom hook with Jest testing

I have developed a custom hook that can display a notification message and automatically remove it after 2 seconds. I am looking to write a test for this functionality, but as someone new to writing tests, I'm unsure of the best approach. Can anyone p ...

Difficulty fetching data on the frontend with Typescript, React, Vite, and Express

I'm currently working on an app utilizing Express in the backend and React in the frontend with typescript. This is also my first time using Vite to build the frontend. While my APIs are functioning correctly, I am facing difficulties fetching data on ...

Is it necessary to refresh the entire component following a Post Request?

I am working on a straightforward list component that displays all the records. Upon mounting, it makes a GET call to retrieve all the records from the database and store them in the state. Additionally, there is a dialog available for adding a new record ...