【问题标题】:move two layers together with jcanvas与 jcanvas 一起移动两层
【发布时间】:2015-08-06 06:28:10
【问题描述】:

使用jcanvas,我如何链接两个可拖动的图层以使它们一起移动。

例如。圆圈和文档图标是两个不同的层。我怎么拥有它们
a) 在同一层上绘制或
b) 一起移动

  // document
      .drawArc({
      layer: true,
      groups: ['document'],
      fillStyle: 'yellow',
      x: 100, y: 250,
      radius: 50
      })

      .drawImage({
      groups: ['document'],
      source: "img/document.jpg",
      x: 100, y: 250,
      width:40, height: 40,
      layer: true
    })


    $('canvas').setLayerGroup('document', {
      draggable: true,
      bringToFront: true
    })

【问题讨论】:

  • 我的解决方案是使用 svg 图像而不是单独绘制零件。也许其他人可以提出问题的答案。文档没有说明这个用例。

标签: html5-canvas jcanvas


【解决方案1】:

您可以使用dragGroups:[] 完成此操作

代码在这里

    $('canvas').drawArc({
            layer: true,
            groups: ['document'],
            dragGroups: ['document'],
            draggable: true,
            fillStyle: 'yellow',
            x: 100, y: 250,
            radius: 50
        })

        .drawImage({
            groups: ['document'],
            dragGroups: ['document'],
            draggable: true,
            source: "img/document.jpg",
            x: 100, y: 250,
            width: 40, height: 40,
            layer: true
        }).drawLayers();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-17
    • 2013-12-29
    • 2022-08-18
    • 2012-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多