2020-03-13 19:04:34 +08:00
|
|
|
import G6, { Graph, TreeGraph } from '../../src';
|
2020-03-13 18:37:08 +08:00
|
|
|
|
|
|
|
const div = document.createElement('div');
|
|
|
|
div.id = 'container';
|
|
|
|
document.body.appendChild(div);
|
|
|
|
|
2020-03-13 19:04:34 +08:00
|
|
|
describe('dragenter dragleave', () => {
|
|
|
|
const data = {
|
|
|
|
nodes: [{
|
|
|
|
id: 'node1',
|
|
|
|
x: 100,
|
|
|
|
y: 100
|
|
|
|
}, {
|
|
|
|
id: 'node2',
|
|
|
|
x: 200,
|
|
|
|
y: 100
|
|
|
|
}],
|
|
|
|
edges: []
|
|
|
|
};
|
|
|
|
const graph = new Graph({
|
|
|
|
container: 'container',
|
|
|
|
width: 500,
|
|
|
|
height: 500,
|
|
|
|
modes: {
|
|
|
|
default: ['drag-node']
|
|
|
|
}
|
|
|
|
});
|
|
|
|
graph.data(data);
|
|
|
|
graph.render();
|
|
|
|
it('dragenter', () => {
|
|
|
|
graph.on('node:dragenter', e => {
|
|
|
|
console.log('dragenter')
|
|
|
|
});
|
|
|
|
graph.on('node:dragleave', e => {
|
|
|
|
console.log('dragleave')
|
|
|
|
});
|
|
|
|
graph.on('node:mouseenter', e => {
|
|
|
|
console.log('mouseenter')
|
|
|
|
});
|
|
|
|
graph.on('node:mouseleave', e => {
|
|
|
|
console.log('mouseleave')
|
|
|
|
});
|
|
|
|
graph.on('node:dragover', e => {
|
|
|
|
console.log('dragover')
|
|
|
|
});
|
|
|
|
graph.destroy();
|
|
|
|
});
|
|
|
|
});
|
2020-03-13 18:37:08 +08:00
|
|
|
|
2020-03-13 19:04:34 +08:00
|
|
|
// closes: #1026
|
|
|
|
describe('empty data array + fitview', () => {
|
2020-03-13 18:37:08 +08:00
|
|
|
const data = {
|
|
|
|
nodes: [],
|
|
|
|
edges: []
|
|
|
|
};
|
|
|
|
const graph = new Graph({
|
|
|
|
container: 'container',
|
|
|
|
width: 500,
|
|
|
|
height: 500,
|
|
|
|
fitView: true
|
|
|
|
});
|
|
|
|
graph.data(data);
|
2020-03-13 19:04:34 +08:00
|
|
|
it('empty data array + fitview', () => {
|
2020-03-13 18:37:08 +08:00
|
|
|
graph.render();
|
|
|
|
});
|
|
|
|
});
|