2018-06-05 23:58:10 +08:00
|
|
|
/**
|
|
|
|
* @fileOverview 缩略图
|
|
|
|
* @author huangtonger@aliyun.com
|
|
|
|
*/
|
2018-06-13 17:38:00 +08:00
|
|
|
const G6 = require('../../src/index');
|
2018-06-05 23:58:10 +08:00
|
|
|
const Minimap = require('./minimap');
|
|
|
|
|
|
|
|
class Plugin {
|
|
|
|
constructor(options) {
|
|
|
|
this.options = options;
|
|
|
|
}
|
|
|
|
init() {
|
|
|
|
const graph = this.graph;
|
|
|
|
const minimap = new Minimap({
|
|
|
|
getGraph() {
|
|
|
|
return graph;
|
|
|
|
},
|
|
|
|
...this.options
|
|
|
|
});
|
|
|
|
graph.on('afterchange', () => {
|
|
|
|
minimap.renderBackground();
|
|
|
|
minimap.renderViewPort();
|
|
|
|
});
|
2018-06-11 21:29:00 +08:00
|
|
|
graph.on('afterlayout', () => {
|
|
|
|
minimap.renderBackground();
|
|
|
|
minimap.renderViewPort();
|
|
|
|
});
|
2018-06-05 23:58:10 +08:00
|
|
|
graph.on('afterviewportchange', () => {
|
|
|
|
minimap.renderViewPort();
|
|
|
|
});
|
|
|
|
this.renderBackground = () => {
|
|
|
|
minimap.renderBackground();
|
|
|
|
};
|
|
|
|
this.renderViewPort = () => {
|
|
|
|
minimap.renderViewPort();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
G6.Plugins['tool.minimap'] = Plugin;
|
|
|
|
|
|
|
|
module.exports = Plugin;
|