| | |
| | | return {
|
| | | position: 'absolute',
|
| | | left: `${layout.leftTrim * scale}px`,
|
| | | top: `${layout.upTrim * scale}px`,
|
| | | bottom: `${layout.upTrim * scale}px`,
|
| | | width: `${layout.width * scale}px`,
|
| | | height: `${layout.height * scale}px`,
|
| | | overflow: 'visible',
|
| | |
| | | return {
|
| | | position: 'absolute',
|
| | | left: `${glassDetail.x * scale}px`,
|
| | | bottom: `${glassDetail.y * scale}px`,
|
| | | top: `${glassDetail.y * scale}px`,
|
| | | width: `${glassDetail.width * scale}px`,
|
| | | height: `${glassDetail.height * scale}px`,
|
| | | backgroundColor: glassDetail.isRemain ? '#f0f0f0' : themeColor.value,
|
| | |
| | | return {
|
| | | position: 'absolute',
|
| | | left: `${glassDetail.x * scale}px`,
|
| | | bottom: `${glassDetail.y * scale}px`,
|
| | | top: `${glassDetail.y * scale}px`,
|
| | | width: `${glassDetail.width * scale}px`,
|
| | | height: `${glassDetail.height * scale}px`,
|
| | | backgroundColor: glassDetail.isRemain ? '#f0f0f0' : themeColor.value,
|
| | |
| | | const threshold = Math.max(glassDetail.width, glassDetail.height) * 0.1;
|
| | |
|
| | | otherRects.forEach(otherRect => {
|
| | | // 水平对齐保持不变
|
| | | // 水平对齐
|
| | | if (Math.abs(glassDetail.x - otherRect.x) < threshold) {
|
| | | glassDetail.x = Math.round((glassDetail.x + otherRect.x) / 2);
|
| | | }
|
| | | // 水平对齐右侧边缘保持不变
|
| | | // 水平对齐右侧边缘
|
| | | if (Math.abs((glassDetail.x + glassDetail.width) - (otherRect.x + otherRect.width)) < threshold) {
|
| | | glassDetail.x = Math.round((otherRect.x + otherRect.width - glassDetail.width));
|
| | | }
|
| | | // 垂直对齐需要调整(基于左下角坐标系)
|
| | | // 垂直对齐
|
| | | if (Math.abs(glassDetail.y - otherRect.y) < threshold) {
|
| | | glassDetail.y = Math.round((glassDetail.y + otherRect.y) / 2);
|
| | | }
|
| | | // 垂直对齐上边缘(基于左下角坐标系)
|
| | | // 垂直对齐上边缘
|
| | | if (Math.abs((glassDetail.y + glassDetail.height) - (otherRect.y + otherRect.height)) < threshold) {
|
| | | glassDetail.y = Math.round((otherRect.y + otherRect.height - glassDetail.height));
|
| | | }
|
| | |
| | | event.preventDefault();
|
| | | if (!moveInterval) {
|
| | | moveInterval = setInterval(() => {
|
| | | moveRect(layoutIndex, rectIndex, 'up');
|
| | | moveRect(layoutIndex, rectIndex, 'down');
|
| | | }, 50);
|
| | | }
|
| | | break;
|
| | |
| | | event.preventDefault();
|
| | | if (!moveInterval) {
|
| | | moveInterval = setInterval(() => {
|
| | | moveRect(layoutIndex, rectIndex, 'down');
|
| | | moveRect(layoutIndex, rectIndex, 'up');
|
| | | }, 50);
|
| | | }
|
| | | break;
|