Jump to content
Search Community

Opacity fade out appears to end abruptly with onComplete callback

dgmldr test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hello,

 

I've discovered a problem when using an opacity animation to 0 along with an onComplete callback that removes the tweened element from the DOM. What essentially I'm experiencing is that the element fades a little bit and then suddenly disappears. Almost as if the onComplete fires before the element reaches 0 opacity.  Click either of the top left buttons to demo.

 

I've found a workaround to adds a timeout to the onComplete callback, delaying the removal of the tweened element by a multiple of the animation duration. Click either of the bottom left buttons to demo. Although the fade-out is smooth and looks right, the hack solution is not desirable. What can be possibly causing the element to "pop" off the page instead of appearing to fade all the way to 0 before onComplete fires

 

Thanks,

DouG

See the Pen e40d4b287e39a021a18c3520e901188b by dgmldrsf (@dgmldrsf) on CodePen

Link to comment
Share on other sites

Hi @dgmldr,

 

Please have a look to your CSS

 

.slds-notification {
    position: relative;
    width: 20rem;
    border: 1px solid #ecebea;
    border-radius: .25rem;
    box-shadow: 0 2px 3px 0 rgba(0,0,0,.2);
    transition-duration: .4s;
    transition-timing-function: ease-in-out;
    transition-property: margin,max-height,opacity,top;
  

  
  

 

If you try ...

 

.slds-notification {
    position: relative;
    width: 20rem;
    border: 1px solid #ecebea;
    border-radius: .25rem;
    box-shadow: 0 2px 3px 0 rgba(0,0,0,.2);
    /* transition-duration: .4s; */
    /* transition-timing-function: ease-in-out; */
    /* transition-property: margin,max-height,opacity,top; */
}

 

 you will have a clear responsibility for the job - done by GreenSock.

 

Kind regards

Mikel

 

 

  • Like 6
  • Thanks 1
Link to comment
Share on other sites

Thank you @mikel

I still need the other CSS property transitions, so I pulled just the opacity transition and it works great!

 

.slds-notification {
    position: relative;
    width: 20rem;
    border: 1px solid #ecebea;
    border-radius: .25rem;
    box-shadow: 0 2px 3px 0 rgba(0,0,0,.2);
    transition-duration: .4s;
    transition-timing-function: ease-in-out;
    /* transition-property: margin,max-height,opacity,top; */
    transition-property: margin,max-height,top;
}

 

Greatly appreciated

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...