0

我发现回调“on”很有趣但限制了https://www.figma.com/plugin-docs/api/properties/figma-on/#docsNav

我有办法在文件更新后触发事件吗?

4

1 回答 1

2

目前没有办法做到这一点。您可以获得的唯一更新类型是选择更改或当前页面更改。这是文档中的一个示例:

figma.on("selectionchange", () => { console.log("changed") })

插件常用来监视节点变化的方法是轮询:只需创建一个间隔或计时器,并检查其中一个属性是否从先前保存的状态发生变化。

let interval = setInterval(checkNodes, 500) // check every 300ms

const node = figma.currentPage.selection[0] // first node in selection
let nodeWidth = node.width // store node properties to watch

function checkNodes() {
  if (nodeWidth !== node.width) {
    // width changed
  }
  nodeWidth = node.width
}
于 2020-11-28T00:07:21.007 回答