diff --git a/package.json b/package.json index 8609aea985..a7fe10e71c 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,7 @@ "screenshot": "node ./bin/screenshot.js", "start": "npm run dev", "test": "torch --compile --renderer --recursive ./test/unit", - "test-live": "torch --compile --interactive --watch --recursive ./test/unit", + "test-live": "torch --compile --interactive --watch --recursive ./test/unit/plugins/tool.tooltip-spec.js", "watch": "webpack --config webpack-dev.config.js", "win-dev": "node ./bin/win-dev.js" }, diff --git a/plugins/tool.tooltip/index.js b/plugins/tool.tooltip/index.js index e6456fd907..07aec51f38 100644 --- a/plugins/tool.tooltip/index.js +++ b/plugins/tool.tooltip/index.js @@ -68,7 +68,7 @@ class Plugin { init() { const graph = this.graph; graph.on('mouseenter', ev => { - this.onMouseEnter(ev); + ev.shape && this.onMouseEnter(ev); }); graph.on('mousemove', ev => { this.onMouseMove(ev); @@ -87,6 +87,9 @@ class Plugin { if (tooltipHtml) { tooltip = Util.createDOM(tooltipHtml); + tooltip.css({ + position: 'absolute' + }); graphContainer.appendChild(tooltip); } else { tooltip = null; @@ -110,7 +113,7 @@ class Plugin { } onMouseLeave() { if (this.tooltip) { - // this.tooltip.destroy(); + this.tooltip.destroy(); this.tooltip = null; } } diff --git a/test/unit/plugins/tool.tooltip-spec.js b/test/unit/plugins/tool.tooltip-spec.js index 199e1d13db..b932b10054 100644 --- a/test/unit/plugins/tool.tooltip-spec.js +++ b/test/unit/plugins/tool.tooltip-spec.js @@ -11,9 +11,9 @@ document.body.appendChild(Util.createDOM(` describe('tooltip test', () => { const tooltip = new Tooltip({ - getHtml({ item }) { + getTooltip() { return ` -
+