avancement planning
This commit is contained in:
+21
-26
@@ -49,9 +49,6 @@ let NzDropDownDirective = (() => {
|
||||
injector = inject(Injector);
|
||||
portal;
|
||||
overlayRef = null;
|
||||
positionStrategy = createFlexibleConnectedPositionStrategy(this.injector, this.elementRef.nativeElement)
|
||||
.withLockedPosition()
|
||||
.withTransformOriginOn('.ant-dropdown');
|
||||
inputVisible$ = new BehaviorSubject(false);
|
||||
nzTrigger$ = new BehaviorSubject('hover');
|
||||
overlayClose$ = new Subject();
|
||||
@@ -74,9 +71,7 @@ let NzDropDownDirective = (() => {
|
||||
});
|
||||
}
|
||||
setDropdownMenuValue(key, value) {
|
||||
if (this.nzDropdownMenu) {
|
||||
this.nzDropdownMenu.setValue(key, value);
|
||||
}
|
||||
this.nzDropdownMenu?.setValue(key, value);
|
||||
}
|
||||
ngAfterViewInit() {
|
||||
if (this.nzDropdownMenu) {
|
||||
@@ -106,7 +101,7 @@ let NzDropDownDirective = (() => {
|
||||
const visible$ = merge(this.inputVisible$, domTriggerVisible$);
|
||||
combineLatest([visible$, this.nzDropdownMenu.isChildSubMenuOpen$])
|
||||
.pipe(map(([visible, sub]) => visible || sub), auditTime(150), distinctUntilChanged(), filter(() => this.platform.isBrowser), takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe((visible) => {
|
||||
.subscribe(visible => {
|
||||
const element = this.nzMatchWidthElement ? this.nzMatchWidthElement.nativeElement : nativeElement;
|
||||
const triggerWidth = element.getBoundingClientRect().width;
|
||||
if (this.nzVisible !== visible) {
|
||||
@@ -114,26 +109,30 @@ let NzDropDownDirective = (() => {
|
||||
}
|
||||
this.nzVisible = visible;
|
||||
if (visible) {
|
||||
const positionStrategy = createFlexibleConnectedPositionStrategy(this.injector, this.elementRef.nativeElement)
|
||||
.withLockedPosition()
|
||||
.withTransformOriginOn('.ant-dropdown');
|
||||
// Listen for placement changes to update the menu classes (arrow position)
|
||||
positionStrategy.positionChanges
|
||||
.pipe(filter(() => Boolean(this.overlayRef)), map(change => getPlacementName(change)), takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe(placement => {
|
||||
if (placement) {
|
||||
this.setDropdownMenuValue('placement', normalizePlacementForClass(placement));
|
||||
}
|
||||
});
|
||||
/** set up overlayRef **/
|
||||
if (!this.overlayRef) {
|
||||
/** new overlay **/
|
||||
this.overlayRef = createOverlayRef(this.injector, {
|
||||
positionStrategy: this.positionStrategy,
|
||||
positionStrategy,
|
||||
minWidth: triggerWidth,
|
||||
disposeOnNavigation: true,
|
||||
hasBackdrop: this.nzBackdrop && this.nzTrigger === 'click',
|
||||
scrollStrategy: createRepositionScrollStrategy(this.injector)
|
||||
});
|
||||
// Listen for placement changes to update the menu classes (arrow position)
|
||||
this.positionStrategy.positionChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(change => {
|
||||
const placement = getPlacementName(change);
|
||||
if (placement) {
|
||||
this.setDropdownMenuValue('placement', normalizePlacementForClass(placement));
|
||||
}
|
||||
});
|
||||
merge(this.overlayRef.backdropClick(), this.overlayRef.detachments(), this.overlayRef
|
||||
.outsidePointerEvents()
|
||||
.pipe(filter((e) => !this.elementRef.nativeElement.contains(e.target))), this.overlayRef.keydownEvents().pipe(filter(e => e.keyCode === ESCAPE && !hasModifierKey(e))))
|
||||
.pipe(filter(e => !this.elementRef.nativeElement.contains(e.target))), this.overlayRef.keydownEvents().pipe(filter(e => e.keyCode === ESCAPE && !hasModifierKey(e))))
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe(() => {
|
||||
this.overlayClose$.next(false);
|
||||
@@ -150,7 +149,7 @@ let NzDropDownDirective = (() => {
|
||||
? setConnectedPositionOffset(POSITION_MAP[position], TOOLTIP_OFFSET_MAP[position])
|
||||
: POSITION_MAP[position];
|
||||
});
|
||||
this.positionStrategy.withPositions(positions);
|
||||
positionStrategy.withPositions(positions);
|
||||
/** reset portal if needed **/
|
||||
if (!this.portal || this.portal.templateRef !== this.nzDropdownMenu.templateRef) {
|
||||
this.portal = new TemplatePortal(this.nzDropdownMenu.templateRef, this.viewContainerRef);
|
||||
@@ -162,16 +161,12 @@ let NzDropDownDirective = (() => {
|
||||
}
|
||||
else {
|
||||
/** detach overlayRef if needed **/
|
||||
if (this.overlayRef) {
|
||||
this.overlayRef.detach();
|
||||
}
|
||||
this.overlayRef?.detach();
|
||||
}
|
||||
});
|
||||
this.nzDropdownMenu.animationStateChange$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(event => {
|
||||
if (event.toState === 'void') {
|
||||
if (this.overlayRef) {
|
||||
this.overlayRef.dispose();
|
||||
}
|
||||
this.overlayRef?.dispose();
|
||||
this.overlayRef = null;
|
||||
}
|
||||
});
|
||||
@@ -308,16 +303,17 @@ class NzDropdownMenuComponent {
|
||||
viewContainerRef = inject(ViewContainerRef);
|
||||
directionality = inject(Directionality);
|
||||
destroyRef = inject(DestroyRef);
|
||||
mouseState$ = new BehaviorSubject(false);
|
||||
noAnimation = inject(NzNoAnimationDirective, { host: true, optional: true });
|
||||
nzMenuService = inject(MenuService);
|
||||
isChildSubMenuOpen$ = this.nzMenuService.isChildSubMenuOpen$;
|
||||
descendantMenuItemClick$ = this.nzMenuService.descendantMenuItemClick$;
|
||||
mouseState$ = new BehaviorSubject(false);
|
||||
animationStateChange$ = new EventEmitter();
|
||||
templateRef;
|
||||
nzOverlayClassName = '';
|
||||
nzOverlayStyle = {};
|
||||
nzArrow = false;
|
||||
placement = 'bottomLeft';
|
||||
templateRef;
|
||||
dir = 'ltr';
|
||||
onAnimationEvent(event) {
|
||||
this.animationStateChange$.emit(event);
|
||||
@@ -329,7 +325,6 @@ class NzDropdownMenuComponent {
|
||||
this[key] = value;
|
||||
this.cdr.markForCheck();
|
||||
}
|
||||
noAnimation = inject(NzNoAnimationDirective, { host: true, optional: true });
|
||||
ngOnInit() {
|
||||
this.directionality.change?.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(direction => {
|
||||
this.dir = direction;
|
||||
|
||||
Reference in New Issue
Block a user