This repository was archived by the owner on May 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
refactor(accordion): use ngAnimate for animations #1675
Merged
chrisirhc
merged 1 commit into
angular-ui:master
from
chrisirhc:feature/accordion-ngAnimate
Mar 21, 2015
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
angular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse']) | ||
angular.module('ui.bootstrap.accordion', []) | ||
|
||
.constant('accordionConfig', { | ||
closeOthers: true | ||
|
@@ -127,4 +127,63 @@ angular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse']) | |
}); | ||
} | ||
}; | ||
}); | ||
}) | ||
|
||
/** | ||
* Animations based on addition and removal of `in` class | ||
* This requires the bootstrap classes to be present in order to take advantage | ||
* of the animation classes. | ||
*/ | ||
.animation('.panel-collapse', function () { | ||
return { | ||
beforeAddClass: function (element, className, done) { | ||
if (className == 'in') { | ||
element | ||
.removeClass('collapse') | ||
.addClass('collapsing') | ||
; | ||
} | ||
done(); | ||
}, | ||
addClass: function (element, className, done) { | ||
if (className == 'in') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any specific reason why you wouldn't use a strict equality operator? (===) |
||
element | ||
.css({height: element[0].scrollHeight + 'px'}) | ||
.one('$animate:close', function closeFn() { | ||
element | ||
.removeClass('collapsing') | ||
.css({height: 'auto'}); | ||
}); | ||
} | ||
done(); | ||
}, | ||
beforeRemoveClass: function (element, className, done) { | ||
if (className == 'in') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any specific reason why you wouldn't use a strict equality operator? (===) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @JoeChapman , I'm sorry, I just saw your comment. Is there a gain in using the strict equality operator when comparing to a string type that isn't number-coercible? Is it for performance? |
||
element | ||
// IMPORTANT: The height must be set before adding "collapsing" class. | ||
// Otherwise, the browser attempts to animate from height 0 (in | ||
// collapsing class) to the given height here. | ||
.css({height: element[0].scrollHeight + 'px'}) | ||
// initially all panel collapse have the collapse class, this removal | ||
// prevents the animation from jumping to collapsed state | ||
.removeClass('collapse') | ||
.addClass('collapsing'); | ||
} | ||
done(); | ||
}, | ||
removeClass: function (element, className, done) { | ||
if (className == 'in') { | ||
element | ||
.css({height: '0'}) | ||
.one('$animate:close', function closeFn() { | ||
element | ||
.removeClass('collapsing') | ||
.addClass('collapse'); | ||
}); | ||
} | ||
done(); | ||
} | ||
}; | ||
}) | ||
|
||
; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any specific reason why you wouldn't use a strict equality operator? (===)