MCPcopy
hub / github.com/apache/echarts / constructor

Method constructor

src/component/tooltip/TooltipHTMLContent.ts:301–369  ·  view source on GitHub ↗
(
        api: ExtensionAPI,
        opt: TooltipContentOption
    )

Source from the content-addressed store, hash-verified

299 private _enableDisplayTransition: boolean;
300
301 constructor(
302 api: ExtensionAPI,
303 opt: TooltipContentOption
304 ) {
305 if (env.wxa) {
306 return null;
307 }
308
309 const el = document.createElement('div');
310 // TODO: TYPE
311 (el as any).domBelongToZr = true;
312 this.el = el;
313 const zr = this._zr = api.getZr();
314
315 const appendTo = opt.appendTo;
316 const container: HTMLElement | null | undefined = appendTo && (
317 isString(appendTo)
318 ? document.querySelector(appendTo)
319 : isDom(appendTo)
320 ? appendTo
321 : isFunction(appendTo) && appendTo(api.getDom())
322 );
323
324 makeStyleCoord(this._styleCoord, zr, container, api.getWidth() / 2, api.getHeight() / 2);
325
326 (container || api.getDom()).appendChild(el);
327
328 this._api = api;
329 this._container = container;
330
331 // FIXME
332 // Is it needed to trigger zr event manually if
333 // the browser do not support `pointer-events: none`.
334
335 const self = this;
336 el.onmouseenter = function () {
337 // clear the timeout in hideLater and keep showing tooltip
338 if (self._enterable) {
339 clearTimeout(self._hideTimeout);
340 self._show = true;
341 }
342 self._inContent = true;
343 };
344 el.onmousemove = function (e) {
345 e = e || (window as any).event;
346 if (!self._enterable) {
347 // `pointer-events: none` is set to tooltip content div
348 // if `enterable` is set as `false`, and `el.onmousemove`
349 // can not be triggered. But in browser that do not
350 // support `pointer-events`, we need to do this:
351 // Try trigger zrender event to avoid mouse
352 // in and out shape too frequently
353 const handler = zr.handler;
354 const zrViewportRoot = zr.painter.getViewportRoot();
355 normalizeEvent(zrViewportRoot, e as ZRRawEvent, true);
356 handler.dispatch('mousemove', e);
357 }
358 };

Callers

nothing calls this directly

Calls 7

getDomMethod · 0.80
makeStyleCoordFunction · 0.70
getZrMethod · 0.65
getWidthMethod · 0.65
getHeightMethod · 0.65
isFunctionFunction · 0.50
hideLaterMethod · 0.45

Tested by

no test coverage detected