correct tooltip test

This commit is contained in:
huangtong.ht 2018-07-11 21:08:43 +08:00
parent 5877b0f784
commit c5e87183d1
3 changed files with 9 additions and 5 deletions

View File

@ -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"
},

View File

@ -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;
}
}

View File

@ -11,9 +11,9 @@ document.body.appendChild(Util.createDOM(`
describe('tooltip test', () => {
const tooltip = new Tooltip({
getHtml({ item }) {
getTooltip() {
return `
<div></div>
<div>dddd</div>
`;
}
});
@ -39,4 +39,5 @@ describe('tooltip test', () => {
plugins: [ tooltip ]
});
graph.read(data);
graph.destroy();
});