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

Ideas for displaying or hiding columns, organizing rows, and keeping headers fixed in a vast data table using jQuery

My data table is massive, filled with an abundance of information. Firstly, I am looking to implement show/hide columns functionality. However, as the number of columns exceeds 10-12, the performance significantly decreases. To address this issue, I have ...

Eliminate gaps between items when using the flex-wrap:wrap attribute

Check out my code on Plunker. Is there a way to eliminate the vertical spacing when using flex-wrap: wrap; #main { width: 200px; height: 200px; border: 1px solid #c3c3c3; display: flex; flex-wrap: wrap; } <div id="main"> < ...

Tips for implementing SVG in background images on Internet Explorer

Having a similar issue to the one discussed in this thread. My background images are functioning properly on all browsers except for versions lower than IE10. After reading through that post, I created a background image in SVG format specifically for IE10 ...

What are the recommended margins for various alphabets?

When displaying text, some alphabets take up more space than others. So how can I adjust the white space between elements '#re1' and '#re2' automatically in the scenario described below? In this code snippet, what is the best way to ad ...

Issue encountered while attempting to start React and Node.js: NPM error

I've encountered some errors in my Node.js and React.js project. I have a server and a React SPA, both working independently. When I use "concurrently" to start them together, I get the following errors: [0] npm ERR! missing script: servernpm run clie ...

The enigma of CSS: How is the width mysteriously set to 0px with no visible CSS styling

Take a look at this snapshot of a webpage I'm currently designing in Chrome Developer Tools: https://i.sstatic.net/SB00j.png The primary rule in the 'Matched CSS Rules' section indicates that the width of the element should be 160px. Howe ...

CSS - my expectations of reduced content were not met

I'm attempting to create a responsive content box that shrinks properly when the browser size is reduced. However, I am facing an issue where the content (yellow) does not shrink and instead overflows horizontally when the browser is minimized too mu ...

Wrapping an anchor tag with a div in Codeigniter

Can a div tag be used inside an anchor function? I have a div with the following CSS: #first{ opacity:0; } Now, I want to include it in my anchor element. Here is the code snippet: <?php if(is_array($databuku)){ echo '<ol>&l ...

The iisnode module is having difficulty in initializing the node.exe process

My iisnode module is having trouble starting the node.exe process. I need to ensure that the node.exe executable is located where it should be according to the system.webServer/iisnode/@nodeProcessCommandLine element in the web.config file. Typically, node ...

When using Next.js, I have found that the global.css file only applies styles successfully when the code is pasted directly into the page.tsx file. However, when attempting to

I recently started exploring nextjs and came across this video "https://www.youtube.com/watch?v=KzqNLDMSdMc&ab_channel=TheBraveCoders" This is when I realized that the CSS styles were not being applied to HeaderTop (the first component cre ...

"Responsive modal with dynamic height based on percentage and a minimum height constraint

My goal is to design a modal dialog that adjusts its height based on a percentage of the browser window height. The modal should maintain a minimum height to ensure it doesn't become too small, and it should dynamically grow, shrink, and re-center as ...

Implementing pagination in React: A step-by-step guide

I am fetching data from the GitHub API, specifically from here Although I have all the necessary data to display, I want to limit it so that only 20 repositories are shown per page. In addition, I prefer not to use any frameworks or plugins for this task ...

What is the best way to extract the active parameter value from React Router within my sidebar or navigation bar in order to generate a link?

I might not be approaching this the right way, but I am following the example from the React Router docs at this link. In my scenario, one of the links from the Sidebar requires a nested parameter (e.g. /bubblegum/:brand/nutrition) so that the Sidebar stru ...

Is there a way for me to keep an image stationary on the page while allowing overlaying text to move?

Currently, I am exploring the process of coding a website that mimics the style of this particular webpage: . I am particularly interested in learning how to create a scrolling effect for text within a fixed area, while keeping the accompanying images st ...

Struggling with the @typescript-eslint/no-var-requires error when trying to include @axe-core/react? Here's a step-by

I have integrated axe-core/react into my project by: npm install --save-dev @axe-core/react Now, to make it work, I included the following code snippet in my index.tsx file: if (process.env.NODE_ENV !== 'production') { const axe = require(&a ...

Dynamic routes in NextJS automatically append a .txt extension to the end of the URL

Issue: When using NextJS, the link <Link href="/link">link</Link> redirects to /link.txt For a simple link like this, HTML <a href="/link">link</a> can be used instead The real problem arises when using NextJS ...

A guide to creating a multi-message box using ReactJS

I'm currently developing a feature that allows users to initiate multiple chatbox conversations, similar to Facebook's popup messenger windows. Users can open, close, and minimize the chatboxes as needed. However, when clicking on multiple users ...

Is it possible to implement -webkit-autofill with MUI on React?

After reading about the -webkit-autofill editing background on 'https://stackoverflow.com/questions/57210325/material-ui-change-autofill-background-color-in-textfield', I attempted to implement it in my application but am unsure of where to add t ...

Displaying the "Ad Blocker Detected" image next to the advertisement

I am attempting to create a feature where if adblock is enabled, an image will display behind the ad banner on my website with the message "Please consider disabling adblock". Unfortunately, it is only showing up as a bordered box. Here is how the box ap ...

ReactJS Redux Provider fails to accept the store

I'm currently in the process of migrating my redux store from using "createStore" to "configureStore" due to the deprecation of "createStore". I am working with ReactJS 17 and TypeScript, with the following versions of Redux / Redux dependencies: &quo ...