leaferjs / leafer-ui

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

上层元素遮住下层元素的情况,应该怎么鼠标移入选中呢? #101

Closed QmagicianEX closed 6 months ago

QmagicianEX commented 6 months ago

image

leaferjs commented 6 months ago

可以通过穿透路径获取:

https://leaferjs.com/ui/guide/property/pick.html

QmagicianEX commented 6 months ago

没有效果,好像加了穿透属性还是只获取到了上层元素,是不是我的参数传的有问题

        const leafer = new Leafer({ view: window })
        const ellipse = new Ellipse({ id: 'block', fill: 'black' })
        const rect = new Rect({ fill: '#32cd79' })
        leafer.add(ellipse)
        leafer.add(rect)
        console.log(
          leafer.pick({ x: 20, y: 20 }, {through: true})
        )
leaferjs commented 6 months ago

坐标传{x:50,y:50}再看看,另外结果需要你自己通过返回数据中的throughPath 查找,那是一个从下往上找到的元素顺序列表

QmagicianEX commented 6 months ago

可以,throughPath里面有,谢了。