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

  2. <small id='kk3ci'></small><noframes id='kk3ci'>

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

      KineticJS 撤消图层:撤消时图层不会消失?

      KineticJS Undo layers: layers don#39;t disappear on undo?(KineticJS 撤消图层:撤消时图层不会消失?)
        <bdo id='8mlOF'></bdo><ul id='8mlOF'></ul>
        <i id='8mlOF'><tr id='8mlOF'><dt id='8mlOF'><q id='8mlOF'><span id='8mlOF'><b id='8mlOF'><form id='8mlOF'><ins id='8mlOF'></ins><ul id='8mlOF'></ul><sub id='8mlOF'></sub></form><legend id='8mlOF'></legend><bdo id='8mlOF'><pre id='8mlOF'><center id='8mlOF'></center></pre></bdo></b><th id='8mlOF'></th></span></q></dt></tr></i><div id='8mlOF'><tfoot id='8mlOF'></tfoot><dl id='8mlOF'><fieldset id='8mlOF'></fieldset></dl></div>

            <legend id='8mlOF'><style id='8mlOF'><dir id='8mlOF'><q id='8mlOF'></q></dir></style></legend>

            <small id='8mlOF'></small><noframes id='8mlOF'>

          1. <tfoot id='8mlOF'></tfoot>

                <tbody id='8mlOF'></tbody>

              1. 本文介绍了KineticJS 撤消图层:撤消时图层不会消失?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我在 Canvas HTML5 中的设计器绘图工具上有一个特定问题.我正在开发一个动作历史系统(撤消和重做).我正在根据 projeqht 对 的回答构建我的系统这个问题 序列化历史数组中的层.核心,解决方案的想法是有效的,但我有一个奇怪的问题.当我点击撤消时,它会创建新图层,但旧图层并没有消失.我会附上我的源代码,我也会附上屏幕截图,这样你就可以看到发生了什么:

                I have a specific problem on my designer drawing tool in Canvas HTML5. I am developing an action history system (Undo & Redo). I am building my system on projeqht's answer on this question with serializing the layers in history array. The core, the idea of the solution is working but I have a strange problem. When I hit Undo it creates the new layers, but the old ones are not disappearing. I will attach my sourcecode and I will attach screenshots as well so you can see what is happening:

                源码:

                var history = Array(null);
                

                var historyStep = 0;

                var historyStep = 0;

                var arrayNonRemovable = Array('moveLayer', 'scaleFromOuterNode', 'scaleFromInnerNode', 'rotateFromOuterSign', 'rotateFromInnerSign' );

                var arrayNonRemovable = Array('moveLayer', 'scaleFromOuterNode', 'scaleFromInnerNode', 'rotateFromOuterSign', 'rotateFromInnerSign' );

                函数 removeLayerByUndoRedo(l){如果 (l){l.destroy();l.draw();阶段.draw();}}

                function removeLayerByUndoRedo(l) { if (l) { l.destroy(); l.draw(); stage.draw(); } }

                function makeHistory(layer, before, after, operation){历史步骤++;如果(历史步骤

                函数 undoHistory(){如果(历史步骤> 0){版本=历史[历史步骤];层=版本.层;var beforeState = history[historyStep].before;

                function makeHistory(layer, before, after, operation) { historyStep++; if (historyStep

                function undoHistory() { if (historyStep>0) { version = history[historyStep]; layer = version.layer; var beforeState = history[historyStep].before;

                    removeLayerByUndoRedo(layer);
                    var layer = Kinetic.Node.create(beforeState, 'container');
                    stage.add(layer);
                
                    stage.draw();
                    historyStep--;
                }
                

                }

                Array.prototype.contains = function(obj) {返回 this.indexOf(obj) > -1;};

                Array.prototype.contains = function(obj) { return this.indexOf(obj) > -1; };

                截图:步骤 1. 创建对象,其中包含更多组,内部有形状(线条、矩形、SVG 绘图)步骤 2、3、4、5:将对象移动到不同的位置(左上、左下、右下和右上):第 6 步:第一次按 Undo(很好地删除旧层并从历史中很好地重新创建它):第 7 步:第二次按 Undo(从历史创建新图层,但不删除旧图层)第 8、9 步:再按 Undo 2 次(与第 7 步相同:创建新图层但保留旧图层):

                Screenshots: Step 1. create the object, which contains more groups with shapes inside (lines, rectangles, SVG drawing) Steps 2, 3, 4, 5: Moving object to different positions (top left, bottom left, bottom right and top right): Step 6: Press Undo for first time (removes the old layer well and recreates it from history well): Step 7: Press Undo for second time (creates new layer from history, but old layer is not removed) Step 8, 9: Press Undo for another 2 times (same happens as in Step 7: creates new layer but old ones remain):

                我做错了吗?我认为它必须是对新图层的引用,因为在第 6 步中删除的图层引用是原始图层,在以下步骤中这些是新图层,所以引用应该是新的?

                Am I doing something wrong? I think it must be something with the reference to the new layers as in Step 6 the removed layers reference is the original layer, in the following steps those are new layers, so reference should be a new one?

                推荐答案

                问题如下:我将图层引用存储在历史数组中.因此,当我创建一个对象时,图层引用存储在历史 [1] 中.我将它移动到 3 次,我将在历史记录中为所有步骤提供相同的参考.当我按下撤消时,我正在销毁从存储的引用中调用它的层,并创建一个新的引用是新的.在历史上我仍然有旧的参考,它指向 NULL.这就是问题所在.

                Here's what the probloem was: I store the layer reference in the history array. So when I create an object the layer reference is stored in history[1]. I move it to 3 times, I will have the same reference in the history for all the steps. When I press undo, I am destroying the layer calling it from the stored reference and I create a new one which reference is a new one. In the history I still have the old reference, which points to NULL. This was the problem.

                我已经修复了它破坏了按名称调用它的旧层.(这仅在您为图层提供唯一名称时才有效):stage.find('.'+layer.getName())[0].destroy()

                I have fixed it destroying the old layer calling it by name. (This only works if you give unique names to layers): stage.find('.'+layer.getName())[0].destroy()

                这篇关于KineticJS 撤消图层:撤消时图层不会消失?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                quot;Status Code:200 OK (from ServiceWorker)quot; in Chrome Network DevTools?(“状态码:200 OK(来自 ServiceWorker)在 Chrome 网络开发工具中?)
                How to set a header for a HTTP GET request, and trigger file download?(如何为 HTTP GET 请求设置标头并触发文件下载?)
                Adding custom HTTP headers using JavaScript(使用 JavaScript 添加自定义 HTTP 标头)
                What is quot;X-Content-Type-Options=nosniffquot;?(什么是“X-Content-Type-Options=nosniff?)
                SQL Query DocumentDB in Azure Functions by an integer not working(通过整数在 Azure Functions 中 SQL 查询 DocumentDB 不起作用)
                Azure Functions [JavaScript / Node.js] - HTTP call, good practices(Azure Functions [JavaScript/Node.js] - HTTP 调用,良好实践)
                <legend id='Jm7bz'><style id='Jm7bz'><dir id='Jm7bz'><q id='Jm7bz'></q></dir></style></legend>
                    • <bdo id='Jm7bz'></bdo><ul id='Jm7bz'></ul>

                          <tbody id='Jm7bz'></tbody>
                      1. <small id='Jm7bz'></small><noframes id='Jm7bz'>

                        <tfoot id='Jm7bz'></tfoot>

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