src/directives/sq-tooltip/sq-tooltip.directive.ts
Angular directive for creating and managing tooltips.
This directive allows you to easily add tooltips to elements in your Angular application. Tooltips can display additional information when hovering or clicking on an element.
See Official Tooltip Documentation
Example :
OnInit
OnDestroy
Selector | [tooltip] |
Properties |
Methods |
Inputs |
HostListeners |
constructor(el: ElementRef, renderer: Renderer2, router: Router, viewContainerRef: ViewContainerRef, documentImported: Document, getWindow: GetWindow)
|
||||||||||||||||||||||||||||
Constructs a new SqTooltipDirective.
Parameters :
|
delay | |
Type : number
|
|
Default value : 0
|
|
The delay in milliseconds before showing the tooltip. |
placement | |
Type : string
|
|
Default value : 'center top'
|
|
The placement of the tooltip relative to the host element. Possible values: 'left top', 'left center', 'left bottom', 'center top', 'center center', 'center bottom', 'right top', 'right center', 'right bottom'. |
theme | |
Type : "light" | "dark"
|
|
Default value : 'dark'
|
|
The theme of the tooltip. Possible values: 'light' or 'dark'. |
tooltip | |
Type : string | null | TemplateRef<any>
|
|
Default value : ''
|
|
The content of the tooltip. Can be a string message or an Angular TemplateRef. |
trigger | |
Type : "hover" | "click"
|
|
Default value : 'hover'
|
|
The trigger for displaying the tooltip. Possible values: 'hover' or 'click'. |
click |
Event listener for the 'click' event to toggle the tooltip on click. |
mouseenter |
Event listener for the 'mouseenter' event to show the tooltip on hover. |
mouseleave |
Event listener for the 'mouseleave' event to hide the tooltip on hover. |
create |
create()
|
Creates the tooltip element and appends it to the DOM.
Returns :
void
|
hide |
hide()
|
Hides the tooltip with a delay to allow for animations, and performs cleanup.
Returns :
void
|
isTouch |
isTouch()
|
Checks if the device has touch support.
Returns :
boolean
|
ngOnDestroy |
ngOnDestroy()
|
Cleans up the directive when it is destroyed, ensuring the tooltip is hidden.
Returns :
void
|
ngOnInit |
ngOnInit()
|
Initializes the directive and subscribes to router events to hide the tooltip on navigation.
Returns :
void
|
onClick |
onClick()
|
Decorators :
@HostListener('click')
|
Event listener for the 'click' event to toggle the tooltip on click.
Returns :
void
|
onMouseEnter |
onMouseEnter()
|
Decorators :
@HostListener('mouseenter')
|
Event listener for the 'mouseenter' event to show the tooltip on hover.
Returns :
void
|
onMouseLeave |
onMouseLeave()
|
Decorators :
@HostListener('mouseleave')
|
Event listener for the 'mouseleave' event to hide the tooltip on hover.
Returns :
void
|
setPosition |
setPosition()
|
Sets the position of the tooltip relative to the host element.
Returns :
void
|
Async show |
show()
|
Shows the tooltip and sets its position.
Returns :
any
|
document |
Type : Document
|
Reference to the Document object for interacting with the DOM. |
Public getWindow |
Type : GetWindow
|
- The GetWindow service for accessing the window object.
|
offset |
Type : number
|
Default value : 10
|
The offset between the tooltip and the host element. |
open |
Default value : false
|
Indicates whether the tooltip is open or closed. Used for internal control. |
tooltipElement |
Type : HTMLElement | null
|
Default value : null
|
Reference to the generated tooltip element. |
window |
Default value : this.getWindow.window()
|
Reference to the window object. |