improve minimap event

This commit is contained in:
huangtong.ht 2018-08-17 12:19:01 +08:00
commit d940fe436f
6 changed files with 13 additions and 21 deletions

View File

@ -29,13 +29,7 @@
layoutCfg: {
maxIteration: 600,
kg: 10,
prevOverlapping: true,
onLayoutComplete: function () {
const minimap = document.getElementById('minimap');
const legend = document.getElementById('legend');
if (minimap !== undefined) minimap.style.display = 'block';
if (legend !== undefined) legend.style.display = 'block';
}
prevOverlapping: true
}
});
let nodeSizeMapper = new Mapper('node', 'userview', 'size', [20, 50], {
@ -92,10 +86,6 @@
height: 500,
});
graph.read(Util.cloneDeep(data));
const minimap = document.getElementById('minimap');
// const legend = document.getElementById('legend');
if (minimap !== undefined) minimap.style.display = 'none';
// if (legend !== undefined) legend.style.display = 'none';
});
</script>

View File

@ -187,7 +187,7 @@ class Layout {
loadingImg.style.setProperty('margin-top', top + 'px');
loading.appendChild(loadingImg);
graph.on('afterdestroy', () => {
if (loading !== null && loading !== undefined) { loading.detroy(); }
if (loading !== null && loading !== undefined) { loading.destroy(); }
});
const worker = new Worker();

View File

@ -205,10 +205,8 @@ class Plugin {
style: preNavi.style
});
}
graph.update(item, {
style
});
item.getKeyShape().attr(style);
graph.draw();
this.preNavi = {
item,
style: preStyle
@ -225,9 +223,8 @@ class Plugin {
});
});
graph.on('node:mouseleave', ev => {
graph.update(ev.item, {
style: this.nodeStyle
});
ev.item.getKeyShape().attr(this.nodeStyle);
graph.draw();
graph.css({
cursor: '-webkit-grab'
});

View File

@ -35,9 +35,8 @@ class Plugin {
const graph = this.graph;
Util.each(freezeElements, freezeElement => {
const freezePoint = freezeElement.get('freezePoint');
const freezable = graph.get('freezable');
const scale = graph.getScale();
if (freezable !== false && freezeElement.isShape && freezePoint && freezeElement.get('visible')) {
if (freezeElement.isShape && freezePoint && freezeElement.get('visible')) {
freezeElement.resetMatrix();
freezeElement.transform([
[ 't', -freezePoint.x, -freezePoint.y ],

View File

@ -28,6 +28,10 @@ class Plugin {
graph.on('afterviewportchange', () => {
minimap.renderViewPort();
});
graph.on('afterfilter', () => {
minimap.renderBackground();
minimap.renderViewPort();
});
this.renderBackground = () => {
minimap.renderBackground();
};

View File

@ -46,6 +46,7 @@ Mixin.AUGMENT = {
* do filter
*/
filter() {
this.emit('beforefilter');
const filters = this.get('filters');
const items = this.getItems();
let filteredItems = this.getItems();
@ -60,6 +61,7 @@ Mixin.AUGMENT = {
}
});
this.draw();
this.emit('afterfilter');
}
};
module.exports = Mixin;