mirror of
https://gitee.com/antv/g6.git
synced 2024-12-05 05:09:07 +08:00
fix: active item problems
This commit is contained in:
parent
2ce6207307
commit
dec5dc6980
@ -101,9 +101,9 @@
|
||||
const legend = document.getElementById('legend');
|
||||
if (minimap !== undefined) minimap.style.display = 'none';
|
||||
if (legend !== undefined) legend.style.display = 'none';
|
||||
setTimeout(()=>{
|
||||
graph.destroy();
|
||||
}, 1000)
|
||||
// setTimeout(()=>{
|
||||
// graph.destroy();
|
||||
// }, 1000)
|
||||
});
|
||||
|
||||
</script>
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@antv/g6",
|
||||
"version": "2.0.5-beta.8",
|
||||
"version": "2.0.5-beta.13",
|
||||
"description": "graph visualization frame work",
|
||||
"main": "build/g6.js",
|
||||
"homepage": "https://github.com/antvis/g6",
|
||||
|
@ -69,7 +69,9 @@ class Plugin {
|
||||
if (!layout) {
|
||||
graph.set('layout', this.layout);
|
||||
}
|
||||
this.graph.activeItem = this.activeItem;
|
||||
this.graph.activeItem = item => {
|
||||
this.activeItem(item);
|
||||
};
|
||||
});
|
||||
graph.on('beforerender', () => {
|
||||
const data = graph.getSource();
|
||||
@ -134,9 +136,11 @@ class Plugin {
|
||||
style: node_style
|
||||
});
|
||||
}
|
||||
activeItem(item, pre_navi) {
|
||||
activeItem(item) {
|
||||
const graph = this.graph;
|
||||
const pre_navi = this.pre_navi;
|
||||
if (Util.isString(item)) {
|
||||
item = this.find(item);
|
||||
item = graph.find(item);
|
||||
}
|
||||
let style = {};
|
||||
let pre_style = {};
|
||||
@ -157,17 +161,17 @@ class Plugin {
|
||||
pre_style = edge_style;
|
||||
} else return;
|
||||
|
||||
// // unactive the previous navigate node
|
||||
if (pre_navi !== {} && pre_navi !== null && pre_navi !== undefined) {
|
||||
this.update(pre_navi.item, {
|
||||
// unactive the previous navigate node
|
||||
if (pre_navi !== {} && pre_navi !== null && pre_navi !== undefined && pre_navi.item !== null) {
|
||||
graph.update(pre_navi.item, {
|
||||
style: pre_navi.style
|
||||
});
|
||||
}
|
||||
|
||||
this.update(item, {
|
||||
graph.update(item, {
|
||||
style
|
||||
});
|
||||
pre_navi = {
|
||||
this.pre_navi = {
|
||||
item,
|
||||
style: pre_style
|
||||
};
|
||||
@ -176,7 +180,7 @@ class Plugin {
|
||||
const graph = this.graph;
|
||||
graph.on('node:mouseenter', ev => {
|
||||
if (ev.item != null) {
|
||||
graph.activeItem(ev.item, this.pre_navi);
|
||||
graph.activeItem(ev.item);
|
||||
}
|
||||
graph.css({
|
||||
cursor: 'pointer'
|
||||
@ -193,7 +197,7 @@ class Plugin {
|
||||
|
||||
graph.on('edge:mouseenter', ev => {
|
||||
if (ev.item != null) {
|
||||
graph.activeItem(ev.item, this.pre_navi);
|
||||
graph.activeItem(ev.item);
|
||||
}
|
||||
});
|
||||
graph.on('edge:mouseleave', ev => {
|
||||
|
@ -28,17 +28,9 @@ class Menu {
|
||||
const menuCfg = this.menuCfg;
|
||||
const container_id = this.container_id;
|
||||
|
||||
const hover_color = '#6af';
|
||||
const custom_color = '#777';
|
||||
const li_style = 'padding-top:5px; padding-bottom:5px; cursor: pointer;';
|
||||
const menuHtml = `<ul id="menu" style = "
|
||||
color: ` + custom_color + `;
|
||||
list-style: none;
|
||||
width: 150px;
|
||||
border: 1px solid #ccc;
|
||||
const menuHtml = `<ul class="menu" style = "
|
||||
position: absolute;
|
||||
display: none;
|
||||
background-color: #fff"></ul>`;
|
||||
display: none;"></ul>`;
|
||||
const menu = Util.createDOM(menuHtml);
|
||||
let parent = graph.getGraphContainer();
|
||||
if (container_id !== '' && container_id !== undefined) {
|
||||
@ -48,7 +40,7 @@ class Menu {
|
||||
|
||||
const list = menuCfg.lists;
|
||||
for (let i = 0; i < list.length; i += 1) {
|
||||
const liHtml = '<li class = "menu_li" style = "' + li_style + ' color: #777;">' + list[i].html + '</li>';
|
||||
const liHtml = '<li class = "menu_li">' + list[i].html + '</li>';
|
||||
const li = Util.createDOM(liHtml);
|
||||
menu.appendChild(li);
|
||||
li.on('click', () => {
|
||||
@ -60,12 +52,6 @@ class Menu {
|
||||
list[i].callBack(node);
|
||||
}
|
||||
});
|
||||
li.addEventListener('mouseover', function() {
|
||||
this.style.setProperty('color', hover_color);
|
||||
});
|
||||
li.addEventListener('mouseout', function() {
|
||||
this.style.setProperty('color', custom_color);
|
||||
});
|
||||
}
|
||||
this.menu = menu;
|
||||
this.hide();
|
||||
|
@ -1 +1 @@
|
||||
module.exports = '2.0.5-beta.9';
|
||||
module.exports = '2.0.5-beta.15';
|
||||
|
Loading…
Reference in New Issue
Block a user