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

159
Views
styling/ adding transition to a slide show

I'm trying to make a random slide show using react hooks and set interval. How can I make a transition/ animation between the images?

thank you!

    const imgArray = [img1, img2,img3,img4]
    const [slideImg, setSlideImg] = useState(imgArray[utilService.getRandIntInclusive(0, imgArray.length - 1)])
   
    useEffect(() => {
        const intervalId = setInterval(() => {
            setSlideImg(imgArray[utilService.getRandIntInclusive(0, imgArray.length - 1)])
        }, 3000)

        return function cleanup() {
            clearInterval(intervalId)
        }
    })

    return (
        <section className='filter flex'>
            <img src={slideImg} alt="" ></img>
          
        </section >)
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can add transition styles to the section.

Example

.flex {
  position:relative;
  height:281px;
  width:450px;
  margin:0 auto;
}

.flex img {
  position:absolute;
  left:0;
  -webkit-transition: opacity 1s ease-in-out;
  -moz-transition: opacity 1s ease-in-out;
  -o-transition: opacity 1s ease-in-out;
  transition: opacity 1s ease-in-out;
}

.flex img.top:hover {
  opacity:0;
} 
about 4 years ago · Juan Pablo Isaza Report
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!