【发布时间】:2021-02-27 04:22:04
【问题描述】:
我发现回调 'on' 很有趣但限制了https://www.figma.com/plugin-docs/api/properties/figma-on/#docsNav
我有办法在文件更新后触发事件吗?
【问题讨论】:
标签: javascript plugins figma
我发现回调 'on' 很有趣但限制了https://www.figma.com/plugin-docs/api/properties/figma-on/#docsNav
我有办法在文件更新后触发事件吗?
【问题讨论】:
标签: javascript plugins figma
目前没有办法做到这一点。您可以获得的唯一更新类型是选择更改或当前页面更改。这是一个例子from the docs:
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
}
【讨论】: