Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

103
Views
How can I split letters and animate its position property based on some condition

I am trying to make an alphabet soup like in this CodePen using react.

The problem i'm facing at present is that I want to display the split result inside my main component. At present i'm able to animate its CSS property a bit but unable to display the split result.

My present result inside CodeSandbox

My code is as below:

          import React from "react";
    
    export default function SlideCard(props) {
      const { id, idx, title } = props;
      const inputText = title;
    
      const scatter = {
        position: "absolute",
        top: "",
        left: "",
        zIndex: "initial",
        transition: "left 2s, top 2s"
      };
    
      if (id !== idx) {
        //split if not active//
        inputText.split("").map((letter) => {
          var randLeft = Math.floor(Math.random() * 400);
          var randTop = Math.floor(Math.random() * 200);
          scatter.top = +randTop + "px";
          scatter.left = +randLeft + "px";
          console.log(letter); //How can I use this split inside the main component
          return letter;
        });
      } else {
        scatter.top = "50%";
        scatter.left = "50%";
      }
    
//main component
      return <div style={scatter}>{inputText}</div>;
    }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!