FabricJS double click on objects

前端 未结 6 516
孤街浪徒
孤街浪徒 2021-01-02 08:04

I am trying to perform a special action whenever the user double clicks any object located inside the canvas. I have read the docs and not found any mouse:dblclick

6条回答
  •  南方客
    南方客 (楼主)
    2021-01-02 08:46

    I'm using this workaround:

      var timer = 0;
      canvas.item(0).on('mouseup', function() {
        var d = new Date();
        timer = d.getTime();
      });
      canvas.item(0).on('mousedown', function() {
        var d = new Date();
        if ((d.getTime() - timer) < 300) {
          console.log('double click')
        }
      });
    

提交回复
热议问题