Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

[Collapse] First animation is still ran #5192

Closed
bogdanalexe90 opened this issue Jan 9, 2016 · 3 comments
Closed

[Collapse] First animation is still ran #5192

bogdanalexe90 opened this issue Jan 9, 2016 · 3 comments

Comments

@bogdanalexe90
Copy link
Contributor

Collapse has a strange flickering when is opened by default at first rendering and some delayed content is loaded. I took a look in the collapse directive and the expand() logic is still ran.

// This should add `collapse in` class
if (!scope.$eval(attrs.uibCollapse)) {
          element.addClass('in')
            .addClass('collapse')
            .css({height: 'auto'});
}

function expand() {
    ...
          if ($animateCss) {
            $animateCss(element, {
              addClass: 'in',
              easing: 'ease',

              // if the async content is loaded after this
              // it will cause an animation towards the new scrollHeight

              to: { height: element[0].scrollHeight + 'px' }
            }).start()['finally'](expandDone);
          } else {
            ...
          }
        }

// Still the watcher will trigger expand logic
scope.$watch(attrs.uibCollapse, function(shouldCollapse) {
          if (shouldCollapse) {
            collapse();
          } else {
            expand();
          }
        });

Because we need to skip expand() only for the first rendering we can add a simple check inside the watcher:

scope.$watch(attrs.uibCollapse, function(shouldCollapse) {
          if (shouldCollapse) {
            collapse();
          } else {
            if(arguments[0] !== arguments[1]){
                expand();
            }
          }
        });
@bogdanalexe90 bogdanalexe90 changed the title [Collapse] First animation is still run [Collapse] First animation is still ran Jan 10, 2016
@icfantv
Copy link
Contributor

icfantv commented Jan 11, 2016

@bogdanalexe90, per these instructions, can you please post a plunker that reproduces the issues? Doing this for bugs usually greatly reduces the time it takes for us to diagnose and fix issues. Thanks.

@bogdanalexe90
Copy link
Contributor Author

Please have a look on #4414 it's the same issue. Also you can have a look on my pull request #5199

@icfantv
Copy link
Contributor

icfantv commented Jan 11, 2016

Awesome, thanks.

@wesleycho wesleycho modified the milestones: 1.0.1, 1.0.2, 1.0.3, 1.0.4 Jan 12, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants