leafer
元素所在的 Leafer 引擎。
只读属性
leafer: Leafer
元素所在的 Leafer 引擎。
app: App | Leafer
元素所在的 App 实例(根应用),非 App 结构时为 Leafer。
isLeafer: boolean
元素是否为 Leafer 引擎。
leaferIsCreated: boolean
Leafer 引擎及子元素 创建完成(完成首次创建)。
leaferIsReady: boolean
Leafer 引擎是否 准备就绪(完成首次布局)。
zoomLayer: Group
Leafer 引擎的 缩放平移视图层。
辅助方法
waitLeafer ( item: function, bind?: object )
等待元素有 leafer 属性时执行 item 函数,可通过参数 bind 绑定 item 函数 的 this 对象。
已存在则立即执行。
归属
UI 元素
示例
等待元素被添加到引擎中时,执行回调
ts
ts
// #等待元素被添加到引擎中时,执行回调 (App)
import { App, Rect } from 'leafer-ui'
import '@leafer-in/editor' // 导入图形编辑器插件
import '@leafer-in/viewport' // 导入视口插件 (可选)
const app = new App({ view: window, editor: {} })
const rect = new Rect({ fill: '#32cd79' })
rect.waitLeafer(() => {
rect.draggable = true
})
app.tree.add(rect)