Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Fade Effect

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #188755
    GSG
    Participant

    http://codepen.io/gsg/pen/zxxNPv

    How do you delay the removing part of the.fade class in a more elegant way? I used setTimeout method but isn’t a smooth effect.

    Thanks!

    #188758
    Paulie_D
    Member

    I’m thinking what you are actually after is two effects..one to fade out the existing text and another to fade it in.

    What you have now, when the class is applied, is it jumping immediately to 0 opacity and then fading in.

    Also, you’re changing the text as soon as the class is applied…without enough time for the fade to complete the transition to 0.

    So what I think you want is start the fade out…at the point the opacity is 0 (say 50% through the cycle) change the text and then fade it back in again.

    #188759
    Paulie_D
    Member

    So…we change the animation to start at 1, be 0 by 50% and then back to 1.

    Add a setTimeout to the text change so it occurs halfway through the animation and increase the timeOut of the class toggle to be at the end.

    http://codepen.io/Paulie-D/pen/YPPZLd

    #188774
    GSG
    Participant

    @Paulie_D – Thanks for your solution, definitely I will study in depth the CSS animations.

    SOLVED.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.