🐛 fix: corrigido bug de resize azul e alça cortada nas camadas do canvas

This commit is contained in:
2026-06-08 20:50:30 +00:00
parent 002218fe13
commit 00341ebf64
2 changed files with 43 additions and 13 deletions
+28 -9
View File
@@ -8365,6 +8365,9 @@ document.addEventListener('DOMContentLoaded', () => {
dragStartLeft = ((itemRect.left - parentRect.left) / parentRect.width) * 100; dragStartLeft = ((itemRect.left - parentRect.left) / parentRect.width) * 100;
dragStartTop = ((itemRect.top - parentRect.top) / parentRect.height) * 100; dragStartTop = ((itemRect.top - parentRect.top) / parentRect.height) * 100;
// Previne o highlight azul do browser durante o drag
document.body.style.userSelect = 'none';
document.addEventListener('mousemove', handleCanvasDrag); document.addEventListener('mousemove', handleCanvasDrag);
document.addEventListener('mouseup', stopCanvasDrag); document.addEventListener('mouseup', stopCanvasDrag);
@@ -8404,37 +8407,51 @@ document.addEventListener('DOMContentLoaded', () => {
if (!canvasModeActive) return; if (!canvasModeActive) return;
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
// Garante que o item clicado seja o selecionado
document.querySelectorAll('.canvas-item').forEach(el => el.classList.remove('active-item'));
selectedCanvasItem = item;
item.classList.add('active-item');
updateToolbarForSelected();
isResizingCanvas = true; isResizingCanvas = true;
dragStartX = e.clientX; dragStartX = e.clientX;
dragStartY = e.clientY; dragStartY = e.clientY;
const parentRect = cartazPrintableArea.getBoundingClientRect(); const parentRect = cartazPrintableArea.getBoundingClientRect();
const itemRect = item.getBoundingClientRect(); const itemRect = item.getBoundingClientRect();
dragStartWidth = (itemRect.width / parentRect.width) * 100; dragStartWidth = (itemRect.width / parentRect.width) * 100;
dragStartHeight = (itemRect.height / parentRect.height) * 100; dragStartHeight = (itemRect.height / parentRect.height) * 100;
// Previne seleção de texto durante o drag de resize
document.body.style.userSelect = 'none';
document.addEventListener('mousemove', handleCanvasResize); document.addEventListener('mousemove', handleCanvasResize);
document.addEventListener('mouseup', stopCanvasResize); document.addEventListener('mouseup', stopCanvasResize);
}); });
handle.addEventListener('touchstart', (e) => { handle.addEventListener('touchstart', (e) => {
if (!canvasModeActive) return; if (!canvasModeActive) return;
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
document.querySelectorAll('.canvas-item').forEach(el => el.classList.remove('active-item'));
selectedCanvasItem = item;
item.classList.add('active-item');
updateToolbarForSelected();
isResizingCanvas = true; isResizingCanvas = true;
const touch = e.touches[0]; const touch = e.touches[0];
dragStartX = touch.clientX; dragStartX = touch.clientX;
dragStartY = touch.clientY; dragStartY = touch.clientY;
const parentRect = cartazPrintableArea.getBoundingClientRect(); const parentRect = cartazPrintableArea.getBoundingClientRect();
const itemRect = item.getBoundingClientRect(); const itemRect = item.getBoundingClientRect();
dragStartWidth = (itemRect.width / parentRect.width) * 100; dragStartWidth = (itemRect.width / parentRect.width) * 100;
dragStartHeight = (itemRect.height / parentRect.height) * 100; dragStartHeight = (itemRect.height / parentRect.height) * 100;
document.addEventListener('touchmove', handleCanvasTouchResize, { passive: false }); document.addEventListener('touchmove', handleCanvasTouchResize, { passive: false });
document.addEventListener('touchend', stopCanvasResize); document.addEventListener('touchend', stopCanvasResize);
}); });
@@ -8493,6 +8510,7 @@ document.addEventListener('DOMContentLoaded', () => {
function stopCanvasDrag() { function stopCanvasDrag() {
isDraggingCanvas = false; isDraggingCanvas = false;
document.body.style.userSelect = ''; // Restaura seleção de texto
document.removeEventListener('mousemove', handleCanvasDrag); document.removeEventListener('mousemove', handleCanvasDrag);
document.removeEventListener('mouseup', stopCanvasDrag); document.removeEventListener('mouseup', stopCanvasDrag);
document.removeEventListener('touchmove', handleCanvasTouchDrag); document.removeEventListener('touchmove', handleCanvasTouchDrag);
@@ -8551,6 +8569,7 @@ document.addEventListener('DOMContentLoaded', () => {
function stopCanvasResize() { function stopCanvasResize() {
isResizingCanvas = false; isResizingCanvas = false;
document.body.style.userSelect = ''; // Restaura seleção de texto
document.removeEventListener('mousemove', handleCanvasResize); document.removeEventListener('mousemove', handleCanvasResize);
document.removeEventListener('mouseup', stopCanvasResize); document.removeEventListener('mouseup', stopCanvasResize);
document.removeEventListener('touchmove', handleCanvasTouchResize); document.removeEventListener('touchmove', handleCanvasTouchResize);
+15 -4
View File
@@ -3773,6 +3773,7 @@ code {
background: rgba(255, 255, 255, 0.3); background: rgba(255, 255, 255, 0.3);
border-radius: 8px; border-radius: 8px;
user-select: text; /* Permite selecionar texto interno para edição */ user-select: text; /* Permite selecionar texto interno para edição */
overflow: visible !important; /* Garante que a alça de resize não seja cortada */
} }
.canvas-item:hover { .canvas-item:hover {
@@ -3821,8 +3822,18 @@ code {
.canvas-scene-layer { .canvas-scene-layer {
padding: 0 !important; padding: 0 !important;
background: transparent !important; background: transparent !important;
border-radius: 0 !important; border-radius: 4px !important;
overflow: hidden; overflow: visible !important; /* IMPORTANTE: permite que a alça de resize fique fora do item */
}
/* A imagem dentro da camada fica com overflow clipado no wrapper interno */
.canvas-scene-layer img {
display: block;
width: 100%;
height: 100%;
object-fit: contain;
pointer-events: none;
border-radius: 4px;
} }
.canvas-scene-layer:hover { .canvas-scene-layer:hover {
@@ -3831,8 +3842,8 @@ code {
} }
.canvas-scene-layer.active-item { .canvas-scene-layer.active-item {
border: 2.5px solid #8b5cf6 !important; border: 2px dashed #8b5cf6 !important;
box-shadow: 0 0 14px rgba(139, 92, 246, 0.5); box-shadow: 0 0 14px rgba(139, 92, 246, 0.4);
} }
/* Animação dos dots de loading */ /* Animação dos dots de loading */