View unanswered posts | View active topics It is currently 2019-12-10 12:34



Reply to topic  [ 6 posts ] 
 link的setStyle("icons.names",[""])图片显示不出来 
Author Message
初级会员

Joined: 2012-02-06 15:43
Posts: 51
Post link的setStyle("icons.names",[""])图片显示不出来
link的setStyle("icons.names",[""])图片显示不出来,需要点击一下才能显示出来线上的图片,用的是5.5.5版本


2017-08-30 21:17
Profile
TWaver开发组
User avatar

Joined: 2017-02-22 10:01
Posts: 400
Post Re: link的setStyle("icons.names",[""])图片显示不出来
您好,能把demo贴出来吗?我这边测试是正常的。
Code:
<!DOCTYPE html>
<html>

<head>
  <title>TWaver HTML5 Demo</title>
  <script src="../js/twaver_test.js" type="text/javascript"></script>
  <script>
  var box = new twaver.ElementBox();
  var network = new twaver.vector.Network(box);

  function init() {
    initNetwork();
    initBox();
    this.registerNormalImage("../img/attachment/att1.png", 'att1');
    this.registerNormalImage("../img/attachment/att2.png", 'att2');
  }


  function registerNormalImage(url, name) {
    var image = new Image();
    image.src = url;
    image.onload = function() {
      twaver.Util.registerImage(name, image, image.width, image.height);
      image.onload = null;
      network.invalidateElementUIs();
    };
  }


  function initNetwork() {
    document.body.appendChild(network.getView());
    network.adjustBounds({
      x: 0,
      y: 0,
      width: 800,
      height: 800
    });
  }

  function initBox() {
    var server1 = new twaver.Node();
    server1.setName("server1");
    server1.setLocation(80, 80);
    var server2 = new twaver.Node();
    server2.setName("server2");
    server2.setLocation(300, 300);

    var link = new twaver.Link(server1, server2);
    link.setStyle('link.width', 10);
    link.setStyle('link.color', '#00FF00');
    link.setStyle('icons.colors', ['#FF0000', '#00FF00', null, '#FFFF00']);
    link.setStyle('icons.position', 'center');
    link.setStyle('icons.names', ['att1', 'att2']);
    box.add(server1);
    box.add(server2);
    box.add(link);

  }
  </script>

  <body onload="init();" style="margin:0;">
  </body>

</html>


2017-08-31 9:54
Profile
初级会员

Joined: 2012-02-06 15:43
Posts: 51
Post Re: link的setStyle("icons.names",[""])图片显示不出来
我不是直接放到body里面的,我是在body下面有个div,把canvas加到div里面,然后偶尔就出不来那个线上的图


2017-09-01 8:39
Profile
TWaver开发组
User avatar

Joined: 2017-02-22 10:01
Posts: 400
Post Re: link的setStyle("icons.names",[""])图片显示不出来
还是没遇到您说的那种情况。


2017-09-01 9:33
Profile
初级会员

Joined: 2012-02-06 15:43
Posts: 51
Post Re: link的setStyle("icons.names",[""])图片显示不出来
我放置连线图的页面有很多js代码在处理dom元素,做一些页面数据展示,然后就会偶尔出来这个情况,我也不确定到底是哪里的问题


2017-09-05 9:03
Profile
新手上路

Joined: 2019-04-08 11:31
Posts: 10
Post Re: link的setStyle("icons.names",[""])图片显示不出来
我也遇到这个问题,不过我的link连接的节点是在group里面的,刚开始group是未展开的,需要点击一下group图标,然后link上的icon才显示出来 :cry:

更新:group默认打开也不会显示,需要点击一下link的节点或者连线才行,


再次更新:问题解决了,是因为在注册图片的时候,最后需要调用一下network的invalidateElementUIs(),在image.onload = null后面。 :smile:


2019-04-10 15:11
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron