leaferjs / leafer-ui

一款好用的 Canvas 渲染引擎,革新的体验。高效绘图 、UI 交互(小游戏、互动应用、组态)、图形编辑,前端开发必备~
https://www.leaferjs.com
MIT License
2.38k stars 82 forks source link

元素监听编辑器事件没有触发 #145

Closed 826327700 closed 4 months ago

826327700 commented 4 months ago
const textLayer = new Text({
    fill: 'rgb(50,205,121)',
    text: text,
    editable: true,
    fontSize: 40,
    align: 'center',
    visible:false,
})
this.leafer.tree.add(textLayer)

textLayer.on(EditorEvent.SELECT,(e)=>{
    console.log("SELECT",e)
})
textLayer.on(EditorScaleEvent.SCALE,(e)=>{
    console.log("RESIZE",e)
})
textLayer.on(EditorMoveEvent.MOVE,(e)=>{
    console.log("MOVE",e)
})
textLayer.on(PointerEvent.ENTER,(e)=>{
    console.log("ENTER",e)//这里可以触发 上面的都不触发
})

我希望监听到编辑器的缩放 移动等事件 用于结合自身的业务逻辑,但是不知道哪里没写对 没有触发。

另外问一下,文字元素,在编辑器缩放时,如何做到文字大小也跟着缩放?

leaferjs commented 4 months ago
  1. 得在编辑器上监听 app.editor.on(...),单个元素上没有这个事件
  2. 网站首页的无界云图上做了文字大小跟着缩放,可以去看看,后面我们也会计划支持这个功能
leaferjs commented 4 months ago

已支持文字元素,在编辑器缩放时,如何做到文字大小也跟着缩放, 等待新版本发布~