FabricJS Catch单击组内的对象 [英] FabricJS Catch click on object inside group

查看:233
本文介绍了FabricJS Catch单击组内的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了很多事情,例如计算位置,处理原始fabricjs中确实存在的事件.以前有做过吗?

I have tried many thing like calculating location, handling with the event we do have in original fabricjs. Does any have done this before?

推荐答案

可以通过在fabric.Group对象中添加选项subTargetCheck: true来侦听内部对象上的事件.

It is possible to listen for events on the inner object by adding the option: subTargetCheck: true to the fabric.Group object.

    // create a group
    let group = new fabric.Group([circle, rect], {
        subTargetCheck: true
    });

    circle.on('mousedown', function(e) { 
        // e.target should be the circle
        console.log(e.target);
    });

这篇关于FabricJS Catch单击组内的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆