繁体   English   中英

获取object中目标object的初始state:fabric.js中的修改事件

[英]Obtaining initial state of target object in object:modified event in fabric.js

我有一个使用fabric.js 的绘图应用程序,并且基于github 上的fabric-history 存储库实现了撤消/重做function。 但是,由于这种方法将整个 canvas 状态保存在堆栈中,因此浏览器在处理所有这些数据时很快变得无响应。 我想要一个撤消/重做方法,它只保存在与 canvas 上的 object 交互时更改的 object 而不是整个 object,而不是整个 object Using the object:modified event, I see I can get the target object of the event after it is modified, but I also need the object target state before the modification was made to restore it in an undo. 任何有关如何获得 object 的 state 的建议将不胜感激。

我认为您可以使用saveState方法。 调用此方法后,object 获得_stateProperty object,其中包含 left、top 和其他属性的当前值。 您可以在doc中阅读有关saveState方法的更多信息

我在这里做了一个简单的例子来演示这种方法

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM