I want to show and hide one popup/tooltip on mouse hover.
popups are multiple as below
<div class="hotspot_info pointer" style=" top: {{towerPoint.posY}}%; left: {{towerPoint.posX}}%;" *ngFor="#towerPoint of visualisation.towerPoints">
<div class="tower-details" style=" position: absolute; top: -90px; left: -84%;">
<div class="popover top" style="display: block;">
<div class="arrow" style="left: 50%;"></div>
<h3 class="popover-title">{{towerPoint.tower.name}}</h3>
<div class="popover-content">Tower Name</div>
</div>
</div>
on hover to ".tower-details" I want to show ".popover" and on mouseexit from hide ".popover"
Hovering is a fundamental digital action that involves placing the mouse cursor on the target link or button. Users mainly use the mouse hover action to access sub-menu items.
The mouseleave event is fired at an Element when the cursor of a pointing device (usually a mouse) is moved out of it. mouseleave and mouseout are similar but differ in that mouseleave does not bubble and mouseout does.
This example demonstrates the difference between mousemove, mouseenter and mouseover. The mouseover event triggers when the mouse pointer enters the div element, and its child elements. The mouseenter event is only triggered when the mouse pointer enters the div element.
The hover() function is more high level - it's built to call functions to handle both a mouseenter event and a mouseleave event. It's very convenient for a UI element that has a hover and normal state (e.g. a button.) The mouseover() function specifically binds to the mouseover event.
To listen on a single tag you can use:
@Component({
selector: 'my-component',
directives: [PopUp],
template: `
<div (mouseover)="mouseover=true" (mouseout)="mouseover=false">xxx</div>
<pop-up *ngIf="mouseover">some content</pop-up>
`
})
class MyComponent {
mouseover:boolean;
}
See also What is the difference between the mouseover and mouseenter events?
For a component to listen on itself on the mouse events you can use:
@Component({
selector: 'my-component'
directives: [PopUp],
template: `
xxx
<pop-up *ngIf="mouseover">some content</pop-up>`
})
class MyComponent {
mouseover:boolean;
@HostListener('mouseover')
onMouseOver() {
this.mouseover = true;
}
@HostListener('mouseout')
onMouseOut() {
this.mouseover = false;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With