@morozeckiy/dd-lib 0.9.1 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -265,11 +265,11 @@ html {
265
265
 
266
266
  .cdk-overlay-pane {
267
267
  &.right {
268
- margin-left: 35px;
268
+ margin-left: 8px;
269
269
  }
270
270
 
271
271
  &.left {
272
- margin-right: 35px;
272
+ margin-right: 8px;
273
273
  }
274
274
 
275
275
  &.top {
@@ -933,32 +933,36 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.2", ngImpor
933
933
  }] }] });
934
934
 
935
935
  const TOOLTIP_RIGHT = {
936
- originX: 'start',
937
- originY: 'center',
938
- overlayX: 'start',
936
+ originX: 'end', // привязываемся к правому краю элемента
937
+ originY: 'center', // по центру по вертикали
938
+ overlayX: 'start', // overlay начинается с левого края
939
939
  overlayY: 'center',
940
940
  panelClass: 'right',
941
+ offsetX: 8, // небольшой отступ
941
942
  };
942
943
  const TOOLTIP_BOTTOM = {
943
944
  originX: 'center',
944
- originY: 'bottom',
945
+ originY: 'bottom', // привязываемся к нижнему краю элемента
945
946
  overlayX: 'center',
946
- overlayY: 'top',
947
+ overlayY: 'top', // overlay привязывается сверху
947
948
  panelClass: 'bottom',
949
+ offsetY: 8,
948
950
  };
949
951
  const TOOLTIP_TOP = {
950
952
  originX: 'center',
951
- originY: 'top',
953
+ originY: 'top', // привязываемся к верхнему краю элемента
952
954
  overlayX: 'center',
953
- overlayY: 'bottom',
955
+ overlayY: 'bottom', // overlay привязывается снизу
954
956
  panelClass: 'top',
957
+ offsetY: -8,
955
958
  };
956
959
  const TOOLTIP_LEFT = {
957
- originX: 'end',
960
+ originX: 'start', // привязываемся к левому краю элемента
958
961
  originY: 'center',
959
- overlayX: 'end',
962
+ overlayX: 'end', // overlay привязывается справа
960
963
  overlayY: 'center',
961
964
  panelClass: 'left',
965
+ offsetX: -8,
962
966
  };
963
967
  class TooltipDirective {
964
968
  set position(p) {
@@ -994,8 +998,9 @@ class TooltipDirective {
994
998
  }
995
999
  const clickedInside = this.element.nativeElement.contains(targetElement.target);
996
1000
  if (!clickedInside) {
997
- if (this.overlayRef?.hasAttached() === true) {
998
- this.overlayRef?.detach();
1001
+ if (this.overlayRef?.hasAttached()) {
1002
+ this.overlayRef.dispose();
1003
+ this.overlayRef = null;
999
1004
  }
1000
1005
  }
1001
1006
  }
@@ -1003,12 +1008,9 @@ class TooltipDirective {
1003
1008
  if (!this.ddTooltip) {
1004
1009
  return;
1005
1010
  }
1006
- const overlay = document.getElementsByClassName('cdk-overlay-container')?.[0];
1007
- if (overlay && overlay.firstChild) {
1008
- overlay.removeChild(overlay.firstChild);
1009
- }
1010
- if (this.overlayRef?.hasAttached() === true) {
1011
- this.overlayRef?.detach();
1011
+ if (this.overlayRef?.hasAttached()) {
1012
+ this.overlayRef.dispose();
1013
+ this.overlayRef = null;
1012
1014
  return;
1013
1015
  }
1014
1016
  this.attachTooltip();
@@ -1029,18 +1031,23 @@ class TooltipDirective {
1029
1031
  if (this.withClick) {
1030
1032
  return;
1031
1033
  }
1032
- if (this.overlayRef?.hasAttached() === true) {
1033
- this.overlayRef?.detach();
1034
+ this.detachOverlay();
1035
+ }
1036
+ detachOverlay() {
1037
+ if (this.overlayRef?.hasAttached()) {
1038
+ this.overlayRef.detach();
1034
1039
  }
1035
1040
  }
1036
1041
  ngOnDestroy() {
1037
1042
  this.overlayRef?.dispose();
1038
1043
  }
1039
1044
  attachTooltip() {
1040
- if (this.overlayRef === null) {
1041
- const positionStrategy = this.getPositionStrategy();
1042
- this.overlayRef = this.overlay.create({ positionStrategy });
1045
+ if (this.overlayRef) {
1046
+ this.overlayRef.dispose();
1047
+ this.overlayRef = null;
1043
1048
  }
1049
+ const positionStrategy = this.getPositionStrategy();
1050
+ this.overlayRef = this.overlay.create({ positionStrategy });
1044
1051
  const injector = Injector.create({
1045
1052
  providers: [
1046
1053
  {