Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to group and ungroup elements #1133

Open
jiangxiaoxilsy opened this issue Oct 8, 2024 · 0 comments
Open

How to group and ungroup elements #1133

jiangxiaoxilsy opened this issue Oct 8, 2024 · 0 comments

Comments

@jiangxiaoxilsy
Copy link

jiangxiaoxilsy commented Oct 8, 2024

// 我的代码(Function not effective):
<Moveable
:key="renderKey"
ref="moveableRef"
:draggable="true"
:rotatable="true"
:resizable="true"
:target="targets"
:view-container="rootContainer"
:snappable="true"
:snap-directions="({ top: true, left: true, bottom: true, right: true, center: true, middle: true })"
:element-snap-directions="({ top: true, left: true, bottom: true, right: true, center: true, middle: true })"
:max-snap-element-guideline-distance="70"
:element-guidelines="chartList.map(chart => '.cube' + chart.code)"
@ClickGroup="onClickGroup"
@drAg="onDrag"
@resize="onResize"
@rotate="onRotate"
@Dragend="onDragEnd"
@resizeEnd="onResizeEnd"
@rotateEnd="onRotateEnd"
@dragGroup="onDragGroup"
@resizeGroup="onResizeGroup"
@rotateGroup="onRotateGroup"
@RenderGroup="onRenderGroup"
/>
<Selecto
:key="renderKey + '2'"
ref="selectoRef"
:drag-container="window"
:selectable-targets="['.selecto-area .cube']"
:hit-rate="0"
:select-by-click="true"
:select-from-inside="false"
:toggle-continue-select="[['ctrl'],['shift'],['meta']]"
:ratio="0"
:root-container="rootContainer"
@dragstart="onDragStart"
@selectEnd="onSelectEnd"
/>
onSelectEnd (e) {
this.targets = e.selected?.filter(target => {
const code = target?.getAttribute('data-code')
const _config = this.canvasInst.getChartInst(code)?.config
return (!_config?.locked)
})

  // 点击组件时默认高亮对应图层
  const code = this.targets[0]?.getAttribute('data-code')
  this.canvasInst.updateActiveCoverage(code)
}
// 组合元素
groupItem () {
  let targets = cloneDeep(this.canvasInst.targets)
  console.log('组合元素1', targets)
  const nextGroup = this.groupManager.group(targets, true)
  if (nextGroup) {
    targets = nextGroup
  }
  console.log('组合元素2', nextGroup)
  this.canvasInst.updateTargets(targets)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant