Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for collapse Animations #3838

Closed
bevbomb opened this issue Feb 19, 2018 · 7 comments
Closed

Fix for collapse Animations #3838

bevbomb opened this issue Feb 19, 2018 · 7 comments

Comments

@bevbomb
Copy link

bevbomb commented Feb 19, 2018

Bug description or feature request:

I have put together an example of using the AnimationBuilder to handle the collapse animations. by not relying on the classes from the original collapse methods from bootstrap and just using the builder to handle the start, transition and complete i was able to reproduce the collapse animations.

Plunker/StackBlitz that reproduces the issue:

StackBlitz: https://stackblitz.com/edit/ngx-bootstrap-collapse
Plunker: https://embed.plnkr.co/IdSJviSEK8X2jjxJNI0o/

Versions of ngx-bootstrap, Angular, and Bootstrap:

ngx-bootstrap: Latest

Angular: 5.0.0

Bootstrap: 4.0.0

@evilstiefel
Copy link

This doesn't appear to be working for me either in Chrome or in Safari, even with the link you provided.

@bevbomb
Copy link
Author

bevbomb commented Feb 21, 2018

@evilstiefel I have added a Plunker link as the StackBlitz is working fine for all of my browsers

@duki994
Copy link

duki994 commented Mar 13, 2018

@bevbomb @evilstiefel

You have a bit of a problem with this directive. It can (and will) fire before child views are initialized and checked (example div with table child with *ngFor directive). Initial height will not be full element height so directive will "cut" element view in half.

It is simply fixed by adding ngAfterViewChecked() hook :)

@Directive({
  selector: '[appBsCollapse]',
})
export class CollapseAnimationDirective implements AfterViewChecked {

 ...

  public isViewChecked: boolean = false;

 ..

  ngAfterViewChecked() {
    this.isViewChecked = true;
  }

...

  /* allows to manually toggle content visibility */
  public toggle(): void {
    if (this.isViewChecked) {
      if (this.isExpanded) {
        this.hide();
      } else {
        this.show();
      }
    }

....

}

@bevbomb
Copy link
Author

bevbomb commented Mar 19, 2018

Hey @duki994
Sorry for the late reply! You are completely right :) i probably wouldn't have picked this up until using it in a live situation, I'll add your update in now.

@rodrigoic23
Copy link

Hello, any update on this?

@ParisZX
Copy link

ParisZX commented Aug 10, 2018

Hi, there is a pure css workaround to the collapse animation. I'm using something like this:

.collapse {
  /* setup transition however you like */
  -webkit-transition: max-height 0.5s ease;
  -moz-transition: max-height 0.5s ease;
  -o-transition: max-height 0.5s ease;
  -ms-transition: max-height 0.5s ease;
  transition: max-height 0.5s ease;
  
  /* override display, overflow and visibility */
  display: block!important;
  overflow: hidden!important;
  visibility: visible!important;
  
  max-height: 0;
  
  &.in {
    /* set max-height to something high so that
    it can fit whatever you have inside your collapsible tag.
    Not too high though, because the animation time will be based
    on this value, so if it's too high the animation will be 
    very fast */
    max-height: 1000px;
  }
}

@hc42 hc42 mentioned this issue Nov 16, 2018
5 tasks
@Domainv Domainv added this to the 5.2.0 milestone Jul 3, 2019
@Domainv
Copy link
Contributor

Domainv commented Jul 9, 2019

@Domainv Domainv closed this as completed Jul 9, 2019
@Domainv Domainv removed this from the 5.2.0 milestone Sep 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants