Skip to content

feat(tooltip): make event tooltip display delay configurable #796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,12 @@ export class CalendarTooltipDirective implements OnDestroy {
@Input('tooltipAppendToBody')
appendToBody: boolean; // tslint:disable-line no-input-rename

@Input('tooltipDelay')
delay: number | null = null; // tslint:disable-line no-input-rename

private tooltipFactory: ComponentFactory<CalendarTooltipWindowComponent>;
private tooltipRef: ComponentRef<CalendarTooltipWindowComponent>;
private showTooltipTimeoutId: number | null = null;

constructor(
private elementRef: ElementRef,
Expand All @@ -96,11 +100,22 @@ export class CalendarTooltipDirective implements OnDestroy {

@HostListener('mouseenter')
onMouseOver(): void {
this.show();
if (this.delay === null) {
this.show();
} else {
this.showTooltipTimeoutId = window.setTimeout(
() => this.show(),
this.delay
);
}
}

@HostListener('mouseleave')
onMouseOut(): void {
if (this.showTooltipTimeoutId !== null) {
this.showTooltipTimeoutId = null;
clearTimeout(this.showTooltipTimeoutId);
}
this.hide();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import { PlacementArray } from 'positioning';
let-tooltipPlacement="tooltipPlacement"
let-eventClicked="eventClicked"
let-tooltipTemplate="tooltipTemplate"
let-tooltipAppendToBody="tooltipAppendToBody">
let-tooltipAppendToBody="tooltipAppendToBody"
let-tooltipDelay="tooltipDelay">
<div
class="cal-event"
[style.backgroundColor]="dayEvent.event.color?.secondary"
Expand All @@ -27,6 +28,7 @@ import { PlacementArray } from 'positioning';
[tooltipEvent]="dayEvent.event"
[tooltipTemplate]="tooltipTemplate"
[tooltipAppendToBody]="tooltipAppendToBody"
[tooltipDelay]="tooltipDelay"
(mwlClick)="eventClicked.emit()">
<mwl-calendar-event-actions
[event]="dayEvent.event"
Expand All @@ -47,7 +49,8 @@ import { PlacementArray } from 'positioning';
tooltipPlacement: tooltipPlacement,
eventClicked: eventClicked,
tooltipTemplate: tooltipTemplate,
tooltipAppendToBody: tooltipAppendToBody
tooltipAppendToBody: tooltipAppendToBody,
tooltipDelay: tooltipDelay
}">
</ng-template>
`
Expand All @@ -74,6 +77,9 @@ export class CalendarDayViewEventComponent {
@Input()
tooltipTemplate: TemplateRef<any>;

@Input()
tooltipDelay: number | null;

@Output()
eventClicked: EventEmitter<any> = new EventEmitter();
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export interface DayViewEventResize {
[tooltipPlacement]="tooltipPlacement"
[tooltipTemplate]="tooltipTemplate"
[tooltipAppendToBody]="tooltipAppendToBody"
[tooltipDelay]="tooltipDelay"
[customTemplate]="eventTemplate"
[eventTitleTemplate]="eventTitleTemplate"
[eventActionsTemplate]="eventActionsTemplate"
Expand Down Expand Up @@ -144,6 +145,7 @@ export interface DayViewEventResize {
[tooltipPlacement]="tooltipPlacement"
[tooltipTemplate]="tooltipTemplate"
[tooltipAppendToBody]="tooltipAppendToBody"
[tooltipDelay]="tooltipDelay"
[customTemplate]="eventTemplate"
[eventTitleTemplate]="eventTitleTemplate"
[eventActionsTemplate]="eventActionsTemplate"
Expand Down Expand Up @@ -268,6 +270,13 @@ export class CalendarDayViewComponent implements OnChanges, OnInit, OnDestroy {
@Input()
tooltipAppendToBody: boolean = true;

/**
* The delay in milliseconds before the tooltip should be displayed. If not provided the tooltip
* will be displayed immediately.
*/
@Input()
tooltipDelay: number | null = null;

/**
* A custom template to use to replace the hour segment
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import { PlacementArray } from 'positioning';
let-unhighlightDay="unhighlightDay"
let-eventClicked="eventClicked"
let-tooltipTemplate="tooltipTemplate"
let-tooltipAppendToBody="tooltipAppendToBody">
let-tooltipAppendToBody="tooltipAppendToBody"
let-tooltipDelay="tooltipDelay">
<div class="cal-cell-top">
<span class="cal-day-badge" *ngIf="day.badgeTotal > 0">{{ day.badgeTotal }}</span>
<span class="cal-day-number">{{ day.date | calendarDate:'monthViewDayNumber':locale }}</span>
Expand All @@ -40,6 +41,7 @@ import { PlacementArray } from 'positioning';
[tooltipEvent]="event"
[tooltipTemplate]="tooltipTemplate"
[tooltipAppendToBody]="tooltipAppendToBody"
[tooltipDelay]="tooltipDelay"
mwlDraggable
[class.cal-draggable]="event.draggable"
dragActiveClass="cal-drag-active"
Expand All @@ -60,7 +62,8 @@ import { PlacementArray } from 'positioning';
unhighlightDay: unhighlightDay,
eventClicked: eventClicked,
tooltipTemplate: tooltipTemplate,
tooltipAppendToBody: tooltipAppendToBody
tooltipAppendToBody: tooltipAppendToBody,
tooltipDelay: tooltipDelay
}">
</ng-template>
`,
Expand Down Expand Up @@ -100,6 +103,9 @@ export class CalendarMonthCellComponent {
@Input()
tooltipTemplate: TemplateRef<any>;

@Input()
tooltipDelay: number | null;

@Output()
highlightDay: EventEmitter<any> = new EventEmitter();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export interface CalendarMonthViewEventTimesChangedEvent<
[tooltipPlacement]="tooltipPlacement"
[tooltipAppendToBody]="tooltipAppendToBody"
[tooltipTemplate]="tooltipTemplate"
[tooltipDelay]="tooltipDelay"
[customTemplate]="cellTemplate"
(mwlClick)="dayClicked.emit({ day: day })"
(highlightDay)="toggleDayHighlight($event.event, true)"
Expand Down Expand Up @@ -155,6 +156,13 @@ export class CalendarMonthViewComponent
@Input()
tooltipAppendToBody: boolean = true;

/**
* The delay in milliseconds before the tooltip should be displayed. If not provided the tooltip
* will be displayed immediately.
*/
@Input()
tooltipDelay: number | null = null;

/**
* The start number of the week
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import { PlacementArray } from 'positioning';
let-eventClicked="eventClicked"
let-tooltipTemplate="tooltipTemplate"
let-tooltipAppendToBody="tooltipAppendToBody"
let-tooltipDisabled="tooltipDisabled">
let-tooltipDisabled="tooltipDisabled"
let-tooltipDelay="tooltipDelay">
<div
class="cal-event"
[style.backgroundColor]="weekEvent.event.color?.secondary"
Expand All @@ -28,6 +29,7 @@ import { PlacementArray } from 'positioning';
[tooltipEvent]="weekEvent.event"
[tooltipTemplate]="tooltipTemplate"
[tooltipAppendToBody]="tooltipAppendToBody"
[tooltipDelay]="tooltipDelay"
(mwlClick)="eventClicked.emit()">
<mwl-calendar-event-actions
[event]="weekEvent.event"
Expand All @@ -49,7 +51,8 @@ import { PlacementArray } from 'positioning';
eventClicked: eventClicked,
tooltipTemplate: tooltipTemplate,
tooltipAppendToBody: tooltipAppendToBody,
tooltipDisabled: tooltipDisabled
tooltipDisabled: tooltipDisabled,
tooltipDelay: tooltipDelay
}">
</ng-template>
`
Expand All @@ -67,6 +70,9 @@ export class CalendarWeekViewEventComponent {
@Input()
tooltipDisabled: boolean;

@Input()
tooltipDelay: number | null;

@Input()
customTemplate: TemplateRef<any>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export interface CalendarWeekViewBeforeRenderEvent extends WeekView {
[tooltipPlacement]="tooltipPlacement"
[tooltipTemplate]="tooltipTemplate"
[tooltipAppendToBody]="tooltipAppendToBody"
[tooltipDelay]="tooltipDelay"
[customTemplate]="eventTemplate"
[eventTitleTemplate]="eventTitleTemplate"
[eventActionsTemplate]="eventActionsTemplate"
Expand Down Expand Up @@ -238,6 +239,7 @@ export interface CalendarWeekViewBeforeRenderEvent extends WeekView {
[tooltipTemplate]="tooltipTemplate"
[tooltipAppendToBody]="tooltipAppendToBody"
[tooltipDisabled]="dragActive || timeEventResizes.size > 0"
[tooltipDelay]="tooltipDelay"
[customTemplate]="eventTemplate"
[eventTitleTemplate]="eventTitleTemplate"
[eventActionsTemplate]="eventActionsTemplate"
Expand Down Expand Up @@ -328,6 +330,13 @@ export class CalendarWeekViewComponent implements OnChanges, OnInit, OnDestroy {
@Input()
tooltipAppendToBody: boolean = true;

/**
* The delay in milliseconds before the tooltip should be displayed. If not provided the tooltip
* will be displayed immediately.
*/
@Input()
tooltipDelay: number | null = null;

/**
* The start number of the week
*/
Expand Down