index.d.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { GUI } from '../../core';
  2. import { Group } from '../../shapes';
  3. import type { TooltipOptions, TooltipStyleProps } from './types';
  4. export type { TooltipStyleProps, TooltipOptions };
  5. export declare class Tooltip extends GUI<TooltipStyleProps> {
  6. static tag: string;
  7. get HTMLTooltipElement(): HTMLElement;
  8. getContainer(): HTMLElement;
  9. set position([x, y]: [number, number]);
  10. private get elementSize();
  11. private get HTMLTooltipItemsElements();
  12. private element;
  13. constructor(options: TooltipOptions);
  14. render(attributes: TooltipStyleProps, container: Group): void;
  15. destroy(): void;
  16. /**
  17. * 如果设置了坐标值,显示过程中会立即更新位置并关闭过渡动画
  18. */
  19. show(x?: number, y?: number): void;
  20. hide(): void;
  21. /**
  22. * 初始化容器
  23. */
  24. private initShape;
  25. private prevCustomContentKey;
  26. private renderCustomContent;
  27. /**
  28. * 更新 HTML 上的内容
  29. */
  30. private renderHTMLTooltipElement;
  31. /**
  32. * 根据 position 和指针位置,计算出 tooltip 相对于指针的偏移量
  33. * @param assignPosition {TooltipPosition} tooltip相对于指针的位置,不指定时使用默认参数
  34. */
  35. private getRelativeOffsetFromCursor;
  36. /**
  37. * 将相对于指针的偏移量生效到dom元素上
  38. */
  39. private setOffsetPosition;
  40. /**
  41. * 更新tooltip的位置
  42. */
  43. private updatePosition;
  44. /**
  45. * 计算自动调整位置后的相对位置
  46. * @param offsetX 根据position计算的横向偏移量
  47. * @param offsetY 根据position计算的纵向偏移量
  48. */
  49. private autoPosition;
  50. }