bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

Horizontal collapse does not animate on first expand

Open rizoom opened this issue 10 years ago • 5 comments

Bug description:

Horizontal collapse: If an element is initially collapsed, the first expand does not animate. It works well for vertical collapse.

Link to minimally-working plunker that reproduces the issue:

http://plnkr.co/edit/iVN0bWeKUCjRdjzTHZKy?p=preview the divs are initially collapsed, clicking on the buttons allow to expand/collapse them. The horizontal one will not animate on the first expand.

Working plunker (dirty fix): http://plnkr.co/edit/8Q0uRsyByKSsg3IEFOTZ?p=preview

init function of uibCollapse directive has been changed to:

        function init() {
          horizontal = !!('horizontal' in attrs);
          if (horizontal) {
            css = {
              width: 'auto',
              height: 'inherit'
            };
            cssTo = {width: '0'};
          } else {
            css = {
              width: 'inherit',
              height: 'auto'
            };
            cssTo = {height: '0'};
          }
          // changes here
          var collapsed = scope.$eval(attrs.uibCollapse);
          if (!collapsed ) {
            element.addClass('in')
          }
            element
              .addClass('collapse')
              .attr('aria-expanded', !collapsed )
              .attr('aria-hidden', collapsed )
              .css(css);
        }

Version of Angular, UIBS, and Bootstrap

Angular: 1.5.3 UIBS: 1.3.3 + horizontal collapse patch (see PR #6010) Bootstrap: 3.3.6

rizoom avatar Jun 24 '16 14:06 rizoom

@rizoom thanks for reporting this and for doing some initial investigation. We'll take a look.

icfantv avatar Jun 25 '16 04:06 icfantv

I want to say that is intentional.

wesleycho avatar Jun 29 '16 20:06 wesleycho

@wesleycho Do you mean that component cannot be initialized in a collapsed state, or that the animation should not run the first expand animation if initially collapsed?

Ok if you say that components initially collapsed are not supported, but for the second case, vertical and horizontal cases are inconsistent, because as stated above, the vertical one does animate (see first plunker).

rizoom avatar Jun 30 '16 08:06 rizoom

Ah, I see the Plunker - this is a bug for sure.

wesleycho avatar Aug 09 '16 09:08 wesleycho

I investigated this more carefully, and this turns out to not be a bug, but a documentation issue - see this Plunker to see it working. This is specifically an issue with how CSS flows in a container, and how the horizontal collapse goes from 0px to the full size, which causes a change in the height of the container.

This is addressed in #6183.

wesleycho avatar Aug 20 '16 03:08 wesleycho