🐛 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;
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('mouseup', stopCanvasDrag);
@@ -8404,37 +8407,51 @@ document.addEventListener('DOMContentLoaded', () => {
if (!canvasModeActive) return;
e.stopPropagation();
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;
dragStartX = e.clientX;
dragStartY = e.clientY;
const parentRect = cartazPrintableArea.getBoundingClientRect();
const itemRect = item.getBoundingClientRect();
dragStartWidth = (itemRect.width / parentRect.width) * 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('mouseup', stopCanvasResize);
});
handle.addEventListener('touchstart', (e) => {
if (!canvasModeActive) return;
e.stopPropagation();
e.preventDefault();
document.querySelectorAll('.canvas-item').forEach(el => el.classList.remove('active-item'));
selectedCanvasItem = item;
item.classList.add('active-item');
updateToolbarForSelected();
isResizingCanvas = true;
const touch = e.touches[0];
dragStartX = touch.clientX;
dragStartY = touch.clientY;
const parentRect = cartazPrintableArea.getBoundingClientRect();
const itemRect = item.getBoundingClientRect();
dragStartWidth = (itemRect.width / parentRect.width) * 100;
dragStartHeight = (itemRect.height / parentRect.height) * 100;
document.addEventListener('touchmove', handleCanvasTouchResize, { passive: false });
document.addEventListener('touchend', stopCanvasResize);
});
@@ -8493,6 +8510,7 @@ document.addEventListener('DOMContentLoaded', () => {
function stopCanvasDrag() {
isDraggingCanvas = false;
document.body.style.userSelect = ''; // Restaura seleção de texto
document.removeEventListener('mousemove', handleCanvasDrag);
document.removeEventListener('mouseup', stopCanvasDrag);
document.removeEventListener('touchmove', handleCanvasTouchDrag);
@@ -8551,6 +8569,7 @@ document.addEventListener('DOMContentLoaded', () => {
function stopCanvasResize() {
isResizingCanvas = false;
document.body.style.userSelect = ''; // Restaura seleção de texto
document.removeEventListener('mousemove', handleCanvasResize);
document.removeEventListener('mouseup', stopCanvasResize);
document.removeEventListener('touchmove', handleCanvasTouchResize);