Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

远程请求来的数据不能拖动到右边画布(刷新页面之后不可以,代码热更新是可以的) #61

Open
bingyuea opened this issue Jan 6, 2021 · 5 comments

Comments

@bingyuea
Copy link

bingyuea commented Jan 6, 2021

`刚开始以为是左边图表没有加载好,然后加载完毕之后还是不能拖动(刷新之后),但是更改代码让代码热更新之后是可以拖动到右边的。 不太清楚是哪里出了问题 注册左边图形代码
image

async getDevices() { getDevice().then(async res => { await registerShape(G6,res.data); registerBehavior(G6); setTimeout(function() { this.devices = _.groupBy(res.data,'typeId') }.bind(this),500) }) },

initPlugin(graph) { // 确保图片加载完毕 let timer = setInterval(function() { const parentNode = this.get('container'); const ghost = createDom('<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"' + ' style="opacity:0"/>'); const children = parentNode.querySelectorAll('.itemPanel img[data-item]') if (children.length) { if (Array.from(children).every(img => img.height > 0)) { setTimeout(function() { each(children,(child,i) => { const addModel = (new Function("return " + child.getAttribute('data-item')))(); child.addEventListener('dragstart',e => { console.log(addModel,'点击!') e.dataTransfer.setDragImage(ghost,0,0); graph.set('addNodeDragging',true); graph.set('addModel',addModel); }); child.addEventListener('dragend',e => { graph.emit('canvas:mouseup',e); graph.set('addNodeDragging',false); graph.set('addModel',null); }); }) }.bind(this),500) clearInterval(timer) } } }.bind(this),1000) }

@bingyuea
Copy link
Author

bingyuea commented Jan 6, 2021

``
image
image

这个是两个graph 对象,第一个是正常的,第二张是所说的问题。

@AmySay
Copy link

AmySay commented Jan 6, 2021

registerShape(G6)
registerBehavior(G6)
这两个方法 重新注册下试试

@bingyuea
Copy link
Author

bingyuea commented Jan 7, 2021

registerShape(G6)
registerBehavior(G6)
这两个方法 重新注册下试试

好像可以了

@wiserliu
Copy link

wiserliu commented Mar 2, 2021

你好,我也遇到了同样的问题,请问怎么解决的

@bingyuea
Copy link
Author

bingyuea commented Mar 2, 2021

你好,我也遇到了同样的问题,请问怎么解决的

加载顺序问题,按照上面的办法试试

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants