Skip to content

Commit

Permalink
added animation reference similar to PanelMenu implementation (#16791)
Browse files Browse the repository at this point in the history
  • Loading branch information
mark7p authored Nov 21, 2024
1 parent d6112fc commit 898d3b9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/app/components/panelmenu/panelmenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ import { ObjectUtils, UniqueComponentId } from 'primeng/utils';
<ng-template *ngTemplateOutlet="itemTemplate; context: { $implicit: processedItem.item }"></ng-template>
</ng-container>
</div>
<div class="p-toggleable-content" [@submenu]="getAnimation(processedItem)">
<div class="p-toggleable-content" [@submenu]="getAnimation(processedItem)" (@submenu.done)="onToggleDone()">
<p-panelMenuSub
*ngIf="isItemVisible(processedItem) && isItemGroup(processedItem) && isItemExpanded(processedItem)"
*ngIf="isItemVisible(processedItem) && isItemGroup(processedItem) && (isItemExpanded(processedItem) || animating)"
[id]="getItemId(processedItem) + '_list'"
[panelId]="panelId"
[items]="processedItem?.items"
Expand Down Expand Up @@ -201,6 +201,8 @@ export class PanelMenuSub {

@ViewChild('list') listViewChild: ElementRef;

animating: boolean | undefined;

constructor(
@Inject(forwardRef(() => PanelMenu)) public panelMenu: PanelMenu,
public el: ElementRef
Expand Down Expand Up @@ -267,6 +269,7 @@ export class PanelMenuSub {

onItemClick(event, processedItem) {
if (!this.isItemDisabled(processedItem)) {
this.animating = true;
this.getItemProp(processedItem, 'command', { originalEvent: event, item: processedItem.item });
this.itemToggle.emit({ processedItem, expanded: !this.isItemActive(processedItem) });
}
Expand All @@ -275,6 +278,10 @@ export class PanelMenuSub {
onItemToggle(event) {
this.itemToggle.emit(event);
}

onToggleDone() {
this.animating = false;
}
}

@Component({
Expand Down

0 comments on commit 898d3b9

Please sign in to comment.