docs: improve JSDoc of TooltipHandler (#219)

development
Thomas Bouffard 2023-08-28 08:34:44 +02:00 committed by GitHub
parent e25fd447be
commit e48f3fa052
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 32 deletions

View File

@ -30,31 +30,22 @@ import type { GraphPlugin } from '../../types';
import EventSource from '../event/EventSource'; import EventSource from '../event/EventSource';
/** /**
* Graph event handler that displays tooltips. {@link Graph#getTooltip} is used to * Graph event handler that displays tooltips.
* get the tooltip for a cell or handle. This handler is built-into
* {@link Graph#tooltipHandler} and enabled using {@link Graph#setTooltips}.
* *
* Example: * {@link Graph#getTooltip} is used to get the tooltip for a cell or handle.
* *
* (code> * This handler is generally enabled using {@link Graph#setTooltips}.
* new mxTooltipHandler(graph);
* (end)
*
* Constructor: mxTooltipHandler
*
* Constructs an event handler that displays tooltips with the specified
* delay (in milliseconds). If no delay is specified then a default delay
* of 500 ms (0.5 sec) is used.
*
* @param graph Reference to the enclosing {@link Graph}.
* @param delay Optional delay in milliseconds.
*/ */
class TooltipHandler implements GraphPlugin { class TooltipHandler implements GraphPlugin {
static pluginId = 'TooltipHandler'; static pluginId = 'TooltipHandler';
/**
* Constructs an event handler that displays tooltips.
*
* @param graph Reference to the enclosing {@link Graph}.
*/
constructor(graph: Graph) { constructor(graph: Graph) {
this.graph = graph; this.graph = graph;
this.delay = 500;
this.graph.addMouseListener(this); this.graph.addMouseListener(this);
this.div = document.createElement('div'); this.div = document.createElement('div');
@ -87,7 +78,8 @@ class TooltipHandler implements GraphPlugin {
div: HTMLElement; div: HTMLElement;
/** /**
* Specifies the zIndex for the tooltip and its shadow. Default is 10005. * Specifies the zIndex for the tooltip and its shadow.
* @default 10005
*/ */
zIndex = 10005; zIndex = 10005;
@ -97,23 +89,25 @@ class TooltipHandler implements GraphPlugin {
graph: Graph; graph: Graph;
/** /**
* Delay to show the tooltip in milliseconds. Default is 500. * Delay to show the tooltip in milliseconds.
* @default 500
*/ */
delay: number; delay = 500;
/** /**
* Specifies if touch and pen events should be ignored. Default is true. * Specifies if touch and pen events should be ignored.
* @default true
*/ */
ignoreTouchEvents = true; ignoreTouchEvents = true;
/** /**
* Specifies if the tooltip should be hidden if the mouse is moved over the * Specifies if the tooltip should be hidden if the mouse is moved over the current cell.
* current cell. Default is false. * @default false
*/ */
hideOnHover = false; hideOnHover = false;
/** /**
* True if this handler was destroyed using <destroy>. * `true` if this handler was destroyed using {@link onDestroy}.
*/ */
destroyed = false; destroyed = false;
@ -125,28 +119,31 @@ class TooltipHandler implements GraphPlugin {
thread: number | null = null; thread: number | null = null;
/** /**
* Specifies if events are handled. Default is false. * Specifies if events are handled.
* @default false
*/ */
enabled = false; enabled = false;
/** /**
* Returns true if events are handled. This implementation * Returns `true` if events are handled.
* returns <enabled>. *
* This implementation returns {@link enabled}.
*/ */
isEnabled() { isEnabled() {
return this.enabled; return this.enabled;
} }
/** /**
* Enables or disables event handling. This implementation * Enables or disables event handling.
* updates <enabled>. *
* This implementation updates {@link enabled}.
*/ */
setEnabled(enabled: boolean) { setEnabled(enabled: boolean) {
this.enabled = enabled; this.enabled = enabled;
} }
/** /**
* Returns <hideOnHover>. * Returns {@link hideOnHover}.
*/ */
isHideOnHover() { isHideOnHover() {
return this.hideOnHover; return this.hideOnHover;

View File

@ -139,8 +139,9 @@ const TooltipMixin: PartialType = {
*****************************************************************************/ *****************************************************************************/
/** /**
* Specifies if tooltips should be enabled. This implementation updates * Specifies if tooltips should be enabled.
* {@link TooltipHandler.enabled} in {@link tooltipHandler}. *
* This implementation updates {@link TooltipHandler.enabled}.
* *
* @param enabled Boolean indicating if tooltips should be enabled. * @param enabled Boolean indicating if tooltips should be enabled.
*/ */