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

160
Views
Another JavaScript Bug: adding transition to element causes extra 0s

Using this lines I tried to add transitions to the element:

transition.style.transform = 'translateY(0)';
            transition.style['-webkit-transition'] = 'opacity 0.9s ease-in-out';

            setTimeout(() => {
                type == 'showContainer' ? transition.style.opacity = 1 :
                                          transition.style.opacity = 0;
            }, 100);

But it sets the transition like this:

element.style {
    transform: translateY(0px);
    transition: opacity 0.9s ease-in-out 0s;
    opacity: 1;
}

The extra 0s is included and ruins the transition!!! How can I fix this?

I just want to add a simple opacity transition ;(

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Couple of things:

To set the style property with it's css name, use style.setProperty(property, value). To set it directly with javascript, the properties have different names, such as backgroundColor as opposed to background-color.

Why do you use a timeout? You can directly set the opacity and the transition. There will be no timing issues.

Use transition instead of -webkit-transition. It is compatible with every browser. And can be directly set on style property.

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!