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

Refactor carousel to work with ngAnimate #2699

Closed

Conversation

chrisirhc
Copy link
Contributor

This is a much cleaner solution that makes use of ngAnimate as it was intended.

It requires a few lines of CSS that will be added by default (similar to how AngularJS adds CSS for ng-hide).
I'll add a Grunt task that will provide the CSS in a separate file so that users that have CSP can add the CSS files separately.

Supercedes #1878.

Fixes #1350 #1513 #1185 #2062 #2235.

Things left:

  • Move CSS into .css file in carousel directory
  • Add Grunt task to compile CSS files into JS that will be loaded when the JS is loaded
  • Add Grunt task to concatenate CSS into one file for CSP users
  • Add prefixes for transition css

@chrisirhc
Copy link
Contributor Author

@pkozlowski-opensource The one thing I'm not so sure about is where to place the css files. I'm keeping them in the /src/ folder for now.

@bazsi
Copy link

bazsi commented Oct 20, 2014

I needed ngAnimate to cooperate with the carousel implementation in angular-bootstrap, so I went ahead and merged this branch into my local tree and it worked flawlessly.

I've even reviewed the code (while trying to understand how carousel works and what was changed), and I liked what I saw, even though my JS knowledge is limited.

Is there an ETA when this code can be merged? It'd be lovely to see a new release so I don't have to keep a patched copy.

Thanks

@pkozlowski-opensource
Copy link
Member

@bazsi I'm guess I'm bottleneck here....
@chrisirhc Chris, could we try to have a hangout sometime after ngEurope to review / discuss ngAnimate-related changes? I was trying to review your code but there are many parts that I don't understand (I'm sorry, my understanding of ngAnmate is really limited...) so just talking those changes over would help to land them sooner than later. WDYT?

@chrisirhc
Copy link
Contributor Author

Sounds good to me. Drop me a message when you're available after ngEurope. Meanwhile I'll try to figure out if AngularJS 1.3's animation updates will affect this and whether it can be any more elegant.

@intellix
Copy link

This fails now in 1.3 as $ngAnimate functionality return promises. So just need to change:

$animate.addClass(slide, directionDirClass, function() {
    slide.removeClass(directionDirClass + ' ' + direction);
    animationDone();
});

to

$animate.addClass(slide, directionDirClass).then(function() {
    slide.removeClass(directionDirClass + ' ' + direction);
    animationDone();
});

I did do this locally and would have done PR but seems i'm using a really old version of this locally.

@chrisirhc chrisirhc modified the milestones: 0.12, 0.13 Nov 16, 2014
@wgorder
Copy link

wgorder commented Dec 23, 2014

@chrisirhc how is this coming. I am using your branch rather then bower since this component is so broken in the current release its basically unusable imo

@wgorder
Copy link

wgorder commented Dec 23, 2014

@intellix Thanks for posting that, I was wondering wth was going on :) I wish this stuff would get merged in.

@JackMorrissey
Copy link

This fixed the numerous issues I was having with Carousel on IOS. Thanks!

@karianna
Copy link
Contributor

karianna commented Feb 2, 2015

@chrisirhc - This can't be automerged at present...

@douglasduteil
Copy link

@chrisirhc I think you should merge it to put an end to it. It is still up to date ?

@wgorder
Copy link

wgorder commented Feb 3, 2015

before it is merged @intellix comment is applicable and should be added as well.

@chrisirhc
Copy link
Contributor Author

I'll rebase it in a bit.

@chrisirhc chrisirhc force-pushed the feature/carousel-animate-pr-2 branch from 1843e4b to 044719b Compare March 16, 2015 20:33
@chrisirhc
Copy link
Contributor Author

Rebased and now it works well with the custom builds.

Note that there's something up with using Angular 1.3 on the demo site. The Custom Builds doesn't seem to work. However, that's a separate issue.

@wgorder
Copy link

wgorder commented Mar 16, 2015

@chrisirhc did you happen to see my comment about noting @intellix post regarding 1.3 incompatibility? Its a few posts up, but I'll quote it here for posterity (not sure if its related to what you are seeing on the demo site):

This fails now in 1.3 as $ngAnimate functionality return promises. So just need to change:

$animate.addClass(slide, directionDirClass, function() {
    slide.removeClass(directionDirClass + ' ' + direction);
    animationDone();
});
to

$animate.addClass(slide, directionDirClass).then(function() {
    slide.removeClass(directionDirClass + ' ' + direction);
    animationDone();
});
I did do this locally and would have done PR but seems i'm using a really old version of this locally.

}(nextSlide, self.currentSlide));
} else {
transitionDone(nextSlide, self.currentSlide);
if ($animate.enabled() && !$scope.noTransition && nextSlide.$element) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only question I have about this check is that there is the potential for nextSlide.$element.data('$$ngAnimateState').disabled to be true - in that case, this would be broken. Do we want to say that we do not support this use case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think if I do this on the $animate:before event for any slide element (and attach it in the slide directive)?
Since it should only mark $currentTransition = true when the animation has started, and it'll only close if it starts. There's a possible race condition where an animation hasn't started but has been queued, but may not matter so much I think, as it's only meant to prevent double-clicking causing a weird transition?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I was just looking at the animation code (in https://github.com/angular/angular.js/blob/g3_v1_2/src/ngAnimate/animate.js#L856-L861), I think the close event always even if the animation is disabled for the element.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you're right - ignore my comment.

@chrisirhc
Copy link
Contributor Author

@wgorder , Thanks for the heads up! I just saw that. I'll fix that for Angular 1.3 since we're going for Angular 1.3 compatibility in the next release.

@wesleycho wesleycho self-assigned this Mar 17, 2015
@chrisirhc chrisirhc force-pushed the feature/carousel-animate-pr-2 branch from 044719b to 5af6224 Compare March 17, 2015 06:28
@chrisirhc
Copy link
Contributor Author

Fixed compatibility with Angular 1.3

@ammar91
Copy link

ammar91 commented Mar 18, 2015

What I would need to do in ui.bootstrap-tpl.js file for these changes to take effect?

@wesleycho
Copy link
Contributor

This PR LGTM.

@chrisirhc
Copy link
Contributor Author

Merged via 431b9c7 . Thanks!

@chrisirhc chrisirhc closed this Mar 19, 2015
@chrisirhc chrisirhc deleted the feature/carousel-animate-pr-2 branch March 27, 2015 05:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Carousel strange transition [bootstrap 3]
10 participants