0

我看到拖拽的示例是这样的:

// set drag bounds after instantiation
shape.setDragBounds({
  top: 0,
  left: 0,
  right: 200,
  bottom: 200
});

但是可以将其设置为圆形轨道吗?感谢您的关注。

4

1 回答 1

2

是的,像这样可行:

dragBoundFunc: function(pos) {
        var x = 100;  // your center point
        var y = 100;  // your center point 
        var radius = 50;
        var scale = radius / Math.sqrt(Math.pow(pos.x - x, 2) + Math.pow(pos.y - y, 2)); // distance formula ratio
        if(scale < 1)
          return {
            y: Math.round((pos.y - y) * scale + y),
            x: Math.round((pos.x - x) * scale + x)
          };
        else
          return pos;
      }
于 2013-01-10T14:41:21.337 回答