MCPcopy
hub / github.com/marktext/marktext / mouseOver

Method mouseOver

packages/muya/src/ui/tooltip/index.ts:33–64  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

31 }
32
33 mouseOver(event) {
34 const { target } = event;
35 const toolTipTarget = target.closest('[data-tooltip]');
36 const { eventCenter } = this._muya;
37 if (toolTipTarget && !this._cache.has(toolTipTarget)) {
38 const tooltip = toolTipTarget.getAttribute('data-tooltip');
39 const tooltipEle = document.createElement('div');
40 tooltipEle.textContent = tooltip;
41 tooltipEle.classList.add('mu-tooltip');
42 document.body.appendChild(tooltipEle);
43 position(toolTipTarget, tooltipEle);
44
45 this._cache.set(toolTipTarget, tooltipEle);
46
47 setTimeout(() => {
48 tooltipEle.classList.add('active');
49 });
50
51 const timer = setInterval(() => {
52 if (!document.body.contains(toolTipTarget)) {
53 this.mouseLeave({ target: toolTipTarget });
54 clearInterval(timer);
55 }
56 }, 300);
57
58 eventCenter.attachDOMEvent(
59 toolTipTarget,
60 'mouseleave',
61 this.mouseLeave.bind(this),
62 );
63 }
64 }
65
66 mouseLeave(event) {
67 const { target } = event;

Callers

nothing calls this directly

Calls 8

mouseLeaveMethod · 0.95
closestMethod · 0.80
appendChildMethod · 0.80
containsMethod · 0.80
positionFunction · 0.70
hasMethod · 0.65
addMethod · 0.45
attachDOMEventMethod · 0.45

Tested by

no test coverage detected