简体   繁体   中英

move two layers together with jcanvas

using jcanvas , how do i link two draggable layers such that they move together.
在此处输入图片说明
eg. the circle and document icon are two diff layers. how do i have them
a) draw on the same layer or
b) move together

  // 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
    })

You can do it using dragGroups:[]

Code here

    $('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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM