leafer-ui icon indicating copy to clipboard operation
leafer-ui copied to clipboard

提问:toJSON或者 export 操作之后,交互操作好像都失去了响应

Open a-boom opened this issue 1 year ago • 6 comments

a-boom avatar Apr 19 '24 08:04 a-boom

得上复现代码才能排查到原因

leaferjs avatar Apr 19 '24 09:04 leaferjs

const json = box.toJSON();
        let rectList = json.children;
        rectList = rectList.map(item => {
            item.stroke = undefined
            return item
        })
        const leaferSave = new Leafer({
            width: this.data.mainBoxSize,
            height: this.data.mainBoxSize
        }, json)
        let nowTime = new Date().getTime()
        leaferSave.export(`pixelVerse_${nowTime}.png`).then(res => {
            console.log(res)
            wx.showToast({
                title: '保存成功',
            })
        })

已经确定就是 export 操作之后导致原来的 leafer 无法交互

a-boom avatar Apr 19 '24 09:04 a-boom

之前的版本的leafer传入json会有这个问题,最新版已经修复了 image

leaferjs avatar Apr 19 '24 10:04 leaferjs

image 引入的已经是最新发布的版本了

a-boom avatar Apr 19 '24 15:04 a-boom

const json = box.toJSON();
        let rectList = json.children;
        rectList = rectList.map(item => {
            item.stroke = undefined
            return item
        })
        let leaferSave = new Leafer({
            width: this.data.mainBoxSize,
            height: this.data.mainBoxSize
        })
        const group = new Group(json)
        leaferSave.add(group)
        let nowTime = new Date().getTime()
        leaferSave.export(`custom_${nowTime}.png`,{}).then(res => {
            wx.showToast({
                title: '保存成功',
            })
        })

通过注释代码排查 只要我创建了第二个 leafer(离屏画布) 就会导致页面上的 canvans 所创建的 leafer 无法操作

a-boom avatar Apr 19 '24 15:04 a-boom

收到,谢谢反馈~, 后面修复下

leaferjs avatar Apr 19 '24 23:04 leaferjs