Skip to content

Commit

Permalink
new version
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Rubin authored and Ben Rubin committed Jul 6, 2016
1 parent f379a3f commit 2b0f141
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-material-expansion-panel",
"version": "0.4.3",
"version": "0.4.4",
"description": "Material Design Expansion Panels.",
"main": [
"dist/md-expansion-panel.js",
Expand Down
30 changes: 24 additions & 6 deletions dist/md-expansion-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function expansionPanelDirective() {
expand: epxansionPanelCtrl.expand,
collapse: epxansionPanelCtrl.collapse,
remove: epxansionPanelCtrl.remove,
onRemove: epxansionPanelCtrl.onRemove,
destroy: epxansionPanelCtrl.destroy,
});
}
Expand All @@ -87,6 +88,7 @@ function expansionPanelDirective() {
var stickyContainer;
var topKiller;
var resizeKiller;
var onRemoveCallback;
var isOpen = false;
var isDisabled = false;
var debouncedUpdateScroll = $$rAF.throttle(updateScroll);
Expand All @@ -103,6 +105,7 @@ function expansionPanelDirective() {
vm.collapse = collapse;
vm.remove = remove;
vm.destroy = destroy;
vm.onRemove = onRemove;

$attrs.$observe('disabled', function(disabled) {
isDisabled = (typeof disabled === 'string' && disabled !== 'false') ? true : false;
Expand Down Expand Up @@ -156,6 +159,7 @@ function expansionPanelDirective() {
expand: expand,
collapse: collapse,
remove: remove,
onRemove: onRemove,
componentId: $attrs.mdComponentId
}, $attrs.mdComponentId);
}
Expand Down Expand Up @@ -228,18 +232,31 @@ function expansionPanelDirective() {
$scope.$destroy();
$element.remove();
deferred.resolve();
callbackRemove();
} else {
collapse();
$timeout(function () {
$scope.$destroy();
$element.remove();
deferred.resolve();
callbackRemove();
}, ANIMATION_TIME);
}

return deferred.promise;
}

function onRemove(callback) {
onRemoveCallback = callback;
}

function callbackRemove() {
if (typeof onRemoveCallback === 'function') {
onRemoveCallback();
onRemoveCallback = undefined;
}
}

function destroy() {
$scope.$destroy();
}
Expand Down Expand Up @@ -344,6 +361,7 @@ function expansionPanelDirective() {
* instance.exapand();
* instance.collapse();
* instance.remove();
* instance.onRemove(function () {});
* });
*/
expansionPanelService.$inject = ['$mdComponentRegistry', '$mdUtil', '$log'];
Expand Down Expand Up @@ -741,13 +759,13 @@ function expansionPanelGroupDirective() {
closeOthers(componentId);
}

function remove(componentId) {
return panels[componentId].remove();
function remove(componentId, noAnimation) {
return panels[componentId].remove(noAnimation);
}

function removeAll() {
function removeAll(noAnimation) {
Object.keys(panels).forEach(function (panelId) {
panels[panelId].remove();
panels[panelId].remove(noAnimation);
});
}

Expand Down Expand Up @@ -883,8 +901,8 @@ function expansionPanelGroupService($mdComponentRegistry, $mdUtil, $mdExpansionP
return instance.remove(componentId);
}

function removeAll() {
instance.removeAll();
function removeAll(noAnimation) {
instance.removeAll(noAnimation);
}

function onChange(callback) {
Expand Down
Loading

0 comments on commit 2b0f141

Please sign in to comment.