<legend id='cab6r'><style id='cab6r'><dir id='cab6r'><q id='cab6r'></q></dir></style></legend>

    <small id='cab6r'></small><noframes id='cab6r'>

      • <bdo id='cab6r'></bdo><ul id='cab6r'></ul>
      <tfoot id='cab6r'></tfoot>
    1. <i id='cab6r'><tr id='cab6r'><dt id='cab6r'><q id='cab6r'><span id='cab6r'><b id='cab6r'><form id='cab6r'><ins id='cab6r'></ins><ul id='cab6r'></ul><sub id='cab6r'></sub></form><legend id='cab6r'></legend><bdo id='cab6r'><pre id='cab6r'><center id='cab6r'></center></pre></bdo></b><th id='cab6r'></th></span></q></dt></tr></i><div id='cab6r'><tfoot id='cab6r'></tfoot><dl id='cab6r'><fieldset id='cab6r'></fieldset></dl></div>

        Fabric JS - 将对象发送到后面

        时间:2023-09-06

        <small id='EA0cS'></small><noframes id='EA0cS'>

          <i id='EA0cS'><tr id='EA0cS'><dt id='EA0cS'><q id='EA0cS'><span id='EA0cS'><b id='EA0cS'><form id='EA0cS'><ins id='EA0cS'></ins><ul id='EA0cS'></ul><sub id='EA0cS'></sub></form><legend id='EA0cS'></legend><bdo id='EA0cS'><pre id='EA0cS'><center id='EA0cS'></center></pre></bdo></b><th id='EA0cS'></th></span></q></dt></tr></i><div id='EA0cS'><tfoot id='EA0cS'></tfoot><dl id='EA0cS'><fieldset id='EA0cS'></fieldset></dl></div>
            <tbody id='EA0cS'></tbody>

              <legend id='EA0cS'><style id='EA0cS'><dir id='EA0cS'><q id='EA0cS'></q></dir></style></legend>
              • <bdo id='EA0cS'></bdo><ul id='EA0cS'></ul>

                  <tfoot id='EA0cS'></tfoot>
                  本文介绍了Fabric JS - 将对象发送到后面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  当您选择一个对象(在我的示例中为多边形)时,它会自动移动到前面.我正在寻找一种方法来防止 z 轴上的移动或在选择后将其向后发送,也许有人可以帮忙?

                  When you select an object (in my example a polygon), it gets automatically moved to the Front. I'm searching for a way to prevent the movement on the z-axis or send it backwards after the selection, maybe someone can help?

                  这是一个简单示例的链接:http://jsfiddle.net/98cuf9b7/1/

                  Here is a link to a simple example: http://jsfiddle.net/98cuf9b7/1/

                  当您选择其中一个多边形时,它会移到前面.我尝试在选择后将其向后发送,但即使调用了canvas.sendToBack(object)"函数,它仍然保留在前面.

                  When you select one of the Polygons, it gets moved to the Front. I tried to send it backwards after the selection, but even if the "canvas.sendToBack(object)" function is called, it's still remains in the Front.

                  我的示例中的代码是:

                  var canvas  = new fabric.Canvas('c');
                  
                  var pol = new fabric.Polygon([
                    {x: 200, y: 0},
                    {x: 250, y: 50},
                    {x: 250, y: 100},
                    {x: 150, y: 100},
                    {x: 150, y: 50} ], {
                      left: 250,
                      top: 150,
                      angle: 0,
                      fill: 'green'
                    }
                  );
                  
                  var pol2 = new fabric.Polygon([
                    {x: 200, y: 50},
                    {x: 200, y: 100},
                    {x: 100, y: 100},
                    {x: 100, y: 50} ], {
                      left: 300,
                      top: 200,
                      angle: 0,
                      fill: 'blue'
                    }
                  );
                  canvas.add(pol, pol2);
                  
                  canvas.on('object:selected', function(event) {
                          var object = event.target;
                          canvas.sendToBack(object);
                          //object.sendToBack();
                          console.log("OK");
                    });
                  

                  推荐答案

                  好的,这是因为您使用的是 Fabric 版本.在小提琴中,就像我看到的那样,你已经使用了版本 0.9 .所以它似乎是无论何时选择对象时,它z-index会改变,使其更改它顶部/前面.尝试使用更高版本.在其他版本中,如果一个对象在后面,则即使您选择它,它仍然在后面,则不会出现此问题.这是一个带有更高版本 version(1.4.0) 的演示.在这里,每当您选择对象时,它将向后移动.如果您注释掉向后发送的代码,它将保持在前面,如果在前面,则在后面.

                  Ok so this is happening because of the Fabric version you are using. In fiddle as i can see you have use version0.9. So it seems to be the default behaviour that whenever an object is selected its z-index is changed such that its on the top/front. Try using a later version. In other versions this issue is not there if an object is at the back it remains at the back even if you select it. Here is a the demo with a later version(1.4.0). Here whenever you select the object it will be moved backwards. And if you comment out the sending backwards code it will remain in front if in front and at the back if at the back.

                  var canvas  = new fabric.Canvas('c');
                  
                  var pol = new fabric.Polygon([
                    {x: 200, y: 0},
                    {x: 250, y: 50},
                    {x: 250, y: 100},
                    {x: 150, y: 100},
                    {x: 150, y: 50} ], {
                      left: 250,
                      top: 150,
                      angle: 0,
                      fill: 'green'
                    }
                  );
                  
                  var pol2 = new fabric.Polygon([
                    {x: 200, y: 50},
                    {x: 200, y: 100},
                    {x: 100, y: 100},
                    {x: 100, y: 50} ], {
                      left: 300,
                      top: 200,
                      angle: 0,
                      fill: 'blue'
                    }
                  );
                  canvas.add(pol, pol2);
                  
                  canvas.on('object:selected', function(event) {
                          var object = event.target;
                          canvas.sendToBack(object);
                          //object.sendToBack();
                          console.log("Selected");
                    });
                    

                  <script src="http://cdnjs.cloudflare.com/ajax/libs/fabric.js/1.4.0/fabric.min.js"></script>
                  <canvas id="c" width="500" height="500"></canvas>

                  这篇关于Fabric JS - 将对象发送到后面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:取值 1-31 并将其转换为带有 JavaScript 的序号日期 下一篇:jsTree:progressive_render 与 ajax/从数组渲染节点

                  相关文章

                    <bdo id='iFuFE'></bdo><ul id='iFuFE'></ul>

                    <tfoot id='iFuFE'></tfoot>

                    <small id='iFuFE'></small><noframes id='iFuFE'>

                  1. <legend id='iFuFE'><style id='iFuFE'><dir id='iFuFE'><q id='iFuFE'></q></dir></style></legend>

                      <i id='iFuFE'><tr id='iFuFE'><dt id='iFuFE'><q id='iFuFE'><span id='iFuFE'><b id='iFuFE'><form id='iFuFE'><ins id='iFuFE'></ins><ul id='iFuFE'></ul><sub id='iFuFE'></sub></form><legend id='iFuFE'></legend><bdo id='iFuFE'><pre id='iFuFE'><center id='iFuFE'></center></pre></bdo></b><th id='iFuFE'></th></span></q></dt></tr></i><div id='iFuFE'><tfoot id='iFuFE'></tfoot><dl id='iFuFE'><fieldset id='iFuFE'></fieldset></dl></div>