svg.js 的set可以操作每個(gè)set組合里面的子元素
setGroupAlign (type) {
????????let box = this.group.set.bbox();
????????let last = this.draw.last();
????????// console.log(box)
????????switch(type){
????????????case 'left':
//? ? 保持左對(duì)齊
????????????????this.group.set.x(box.x)?
????????????break;
????????????case 'right':
// 右對(duì)齊會(huì)有元素偏移出去,
????????????????this.group.set.members.forEach(g =>{
????????????????????let width = g.bbox().width
// 移動(dòng)的時(shí)候需要減去當(dāng)前元素的寬度
????????????????????g.x(box.x2-width)
????????????????})
????????????break;
????????????case 'center':
// 統(tǒng)一set里面的中心點(diǎn),居中對(duì)齊
????????????????this.group.set.cx(box.cx, box.cy)
????????????break;
????????????case 'middle':
????????????????this.group.set.cy(box.cy, box.cy)
????????????break;
????????????case 'top':
????????????????this.group.set.y(box.y)
????????????break;
????????????case 'bottom':
//同右對(duì)齊一樣的原理
????????????????this.group.set.members.forEach(g =>{
????????????????????let width = g.bbox().height
????????????????????g.y(box.x2-width)
????????????????})
????????????break;
????????}