From 22db7bfc08ec433e745ddfaac5358a533d33192c Mon Sep 17 00:00:00 2001 From: Vito Date: Thu, 17 Aug 2017 09:21:59 -0700 Subject: [PATCH] [ADF-1096] added cursor strategy to diagram tooltip (#2227) * [ADF-1096] - added cursor strategy to diagram tooltip * [ADF-1096] removed wrong console log * [ADF-1096] removed wrong console log --- .../analytics-report-list.component.ts | 1 - .../tooltip/diagram-tooltip.component.ts | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ng2-components/ng2-activiti-analytics/src/components/analytics-report-list.component.ts b/ng2-components/ng2-activiti-analytics/src/components/analytics-report-list.component.ts index b8586373d8..6880d117ac 100644 --- a/ng2-components/ng2-activiti-analytics/src/components/analytics-report-list.component.ts +++ b/ng2-components/ng2-activiti-analytics/src/components/analytics-report-list.component.ts @@ -93,7 +93,6 @@ export class AnalyticsReportListComponent implements OnInit { this.reportObserver.next(report); }); if (reportId) { - console.log('SELEZIONO IL REPORT!'); this.selectReportByReportId(reportId); } if (this.selectFirst) { diff --git a/ng2-components/ng2-activiti-diagrams/src/components/tooltip/diagram-tooltip.component.ts b/ng2-components/ng2-activiti-diagrams/src/components/tooltip/diagram-tooltip.component.ts index e1a58749ef..e923c3dbe5 100644 --- a/ng2-components/ng2-activiti-diagrams/src/components/tooltip/diagram-tooltip.component.ts +++ b/ng2-components/ng2-activiti-diagrams/src/components/tooltip/diagram-tooltip.component.ts @@ -19,6 +19,7 @@ import { AfterViewInit, Component, ElementRef, Input, OnDestroy, ViewChild } from '@angular/core'; const POSITION = { BOTTOM: 'bottom', LEFT: 'left', RIGHT: 'right', TOP: 'top'}; +const STRATEGY = { CURSOR: 'cursor', ELEMENT: 'element'}; const IS_ACTIVE_CLASS = 'is-active'; @Component({ @@ -42,6 +43,9 @@ export class DiagramTooltipComponent implements AfterViewInit, OnDestroy { @Input() position: string = 'bottom'; + @Input() + strategy: string = 'cursor'; + /** * Set up event listeners for the target element (defined in the data.id) */ @@ -95,11 +99,17 @@ export class DiagramTooltipComponent implements AfterViewInit, OnDestroy { * @param event mouseenter/touchend event */ private handleMouseEnter(event): void { - const props = event.target.getBoundingClientRect(), - top = props.top + (props.height / 2), - marginLeft = -1 * (this.tooltipElement.offsetWidth / 2), - marginTop = -1 * (this.tooltipElement.offsetHeight / 2); + let props; + if(this.strategy === STRATEGY.ELEMENT ) { + props = event.target.getBoundingClientRect(); + }else { + props = {top: (event.pageY - 150), left: event.pageX , width: event.layerX, height: 50}; + } + + let top = props.top + (props.height / 2); + let marginLeft = -1 * (this.tooltipElement.offsetWidth / 2); + let marginTop = -1 * (this.tooltipElement.offsetHeight / 2); let left = props.left + (props.width / 2); if (this.position === POSITION.LEFT || this.position === POSITION.RIGHT) {