@dev-tcloud/tcloud-ui 0.1.7 → 0.1.8

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.
@@ -4370,10 +4370,22 @@ class TCloudUiTooltipDirective {
4370
4370
  constructor(el, renderer) {
4371
4371
  this.el = el;
4372
4372
  this.renderer = renderer;
4373
+ this.remove = false;
4373
4374
  this.info_text = '';
4374
4375
  this._direction = 'top';
4375
4376
  }
4376
4377
  onMouseOver(event) {
4378
+ let hoverInCallback = () => {
4379
+ this.remove = false;
4380
+ };
4381
+ let hoverOutCallback = () => {
4382
+ this.remove = true;
4383
+ const customDiv = document.querySelector('.tc-directive-tooltip');
4384
+ if (customDiv) {
4385
+ customDiv.remove();
4386
+ }
4387
+ };
4388
+ hoverOutCallback;
4377
4389
  const scrollTop = window.scrollY || window.pageYOffset;
4378
4390
  const tooltip = this.renderer.createElement('div');
4379
4391
  const rect = this.el.nativeElement?.getBoundingClientRect();
@@ -4396,20 +4408,37 @@ class TCloudUiTooltipDirective {
4396
4408
  this.renderer.addClass(tooltip, `tc-directive-tooltip-${direction}`);
4397
4409
  const id = this.generateID();
4398
4410
  this.renderer.setAttribute(tooltip, 'id', id);
4399
- const textNode = this.renderer.createText(`${this.info_text}`);
4400
- this.renderer.appendChild(tooltip, textNode);
4401
- this.renderer.appendChild(document.body, tooltip);
4402
- this.start_tooltip(id, height, width, el_position_x, el_position_y, direction);
4411
+ const textNode = this.info_text;
4412
+ if (textNode !== undefined && textNode !== null && textNode !== '') {
4413
+ tooltip.innerHTML = textNode;
4414
+ this.renderer.appendChild(document.body, tooltip);
4415
+ this.start_tooltip(id, height, width, el_position_x, el_position_y, direction);
4416
+ if (tooltip) {
4417
+ tooltip.addEventListener('mouseenter', hoverInCallback);
4418
+ tooltip.addEventListener('mouseleave', hoverOutCallback);
4419
+ }
4420
+ }
4403
4421
  }
4404
4422
  onMouseOut(event) {
4405
- const customDiv = document.querySelector('.tc-directive-tooltip');
4423
+ this.remove = true;
4424
+ this.remove_tooltip(document.querySelector('.tc-directive-tooltip'));
4425
+ }
4426
+ remove_tooltip(customDiv) {
4406
4427
  if (customDiv) {
4407
- customDiv.remove();
4428
+ setTimeout(() => {
4429
+ if (this.remove) {
4430
+ customDiv.remove();
4431
+ }
4432
+ }, 30);
4408
4433
  }
4409
4434
  }
4410
4435
  set TCtooltip(tooltip) {
4411
4436
  if (tooltip) {
4412
- this.info_text = tooltip;
4437
+ if (typeof tooltip === 'object') {
4438
+ }
4439
+ else {
4440
+ this.info_text = tooltip;
4441
+ }
4413
4442
  }
4414
4443
  }
4415
4444
  set TCdirection(direction) {