mirror of
https://gitee.com/antv/g6.git
synced 2024-12-05 05:09:07 +08:00
chore(plugin): modify plugin methods
This commit is contained in:
parent
d505e4a0f8
commit
bdd782cd40
@ -9,7 +9,7 @@ class PluginBase {
|
||||
getDefaultCfg() {
|
||||
return {};
|
||||
}
|
||||
_init(graph) {
|
||||
initPlugin(graph) {
|
||||
const self = this;
|
||||
self.set('graph', graph);
|
||||
const events = self.getEvents();
|
||||
@ -32,7 +32,9 @@ class PluginBase {
|
||||
set(key, val) {
|
||||
this._cfgs[key] = val;
|
||||
}
|
||||
destroy() {
|
||||
destroy() {}
|
||||
destroyPlugin() {
|
||||
this.destroy();
|
||||
const graph = this.get('graph');
|
||||
const events = this._events;
|
||||
each(events, (v, k) => {
|
||||
|
@ -48,7 +48,6 @@ class Grid extends Base {
|
||||
destroy() {
|
||||
const graphContainer = this.get('graph').get('container');
|
||||
graphContainer.removeChild(this.get('container'));
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -286,7 +286,6 @@ class Minimap extends Base {
|
||||
const container = this.get('canvas');
|
||||
this.get('canvas').destroy();
|
||||
container.innerHTML = '';
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,8 +224,8 @@ class Graph extends EventEmitter {
|
||||
_initPlugins() {
|
||||
const self = this;
|
||||
Util.each(self.get('plugins'), plugin => {
|
||||
if (!plugin.destroyed && plugin._init) {
|
||||
plugin._init(self);
|
||||
if (!plugin.destroyed && plugin.initPlugin) {
|
||||
plugin.initPlugin(self);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -926,7 +926,7 @@ class Graph extends EventEmitter {
|
||||
destroy() {
|
||||
this.clear();
|
||||
Util.each(this.get('plugins'), plugin => {
|
||||
plugin.destroy();
|
||||
plugin.destroyPlugin();
|
||||
});
|
||||
this.get('eventController').destroy();
|
||||
this.get('itemController').destroy();
|
||||
|
@ -548,7 +548,7 @@ describe('all node link center', () => {
|
||||
expect(graph.get('plugins').length).to.equal(1);
|
||||
graph.emit('event');
|
||||
expect(count).to.equal(1);
|
||||
plugin.destroy();
|
||||
plugin.destroyPlugin();
|
||||
graph.emit('event');
|
||||
expect(count).to.equal(1);
|
||||
});
|
||||
|
@ -49,7 +49,7 @@ describe('minimap', () => {
|
||||
expect(viewport.style.top).to.equal('20px');
|
||||
expect(viewport.style.width).to.equal('160px');
|
||||
expect(viewport.style.height).to.equal('160px');
|
||||
minimap.destroy();
|
||||
minimap.destroyPlugin();
|
||||
const container = div.childNodes[1];
|
||||
expect(container.innerHTML).to.equal('');
|
||||
graph.zoom(2.5, { x: 250, y: 250 });
|
||||
|
Loading…
Reference in New Issue
Block a user