<div
:style="`padding: 30px 0px;position:absolute; top:${elLeft}px;left:${elTop}px; width:${box_width}px;height:${box_height}px`"
draggable="true" @dragstart="dragstart" @dragend="dragend" ref="box_canvas_drag" id="print" @click.self="bg_click"
@mousedown="mouse_down" @mousemove="mouse_move" @mouseup="mouse_up">
<div class="canvas_box" ref="canvasRefs" :class="{ only_edit: !showControl }" @wheel.prevent="handleWeel"
:style="`transform: scale(${zoom}) rotate(${box_rotate}deg); transformOrigin: ${mouseX}px ${mouseY}px ; width:${box_width}px;height:${box_height}px`"
id="print_box">
<canvas id="canvas" :style="` width:${box_width + 100}px;height:${box_height + 100}px`"></canvas>
</div>
</div>
const zoom = ref(0.55);
const mouseX = ref(0)
const mouseY = ref(0)
const handleWeel = (e: any) => {
console.log(e);
if (e.wheelDelta < 0) {
zoom.value -= 0.05;
} else {
zoom.value += 0.05;
}
console.log(zoom.value);
if (zoom.value <= 0.2) {
zoom.value = 0.2;
} else if (zoom.value >= 2) {
zoom.value = 2;
}
let boundingRect = canvasRefs.value.getBoundingClientRect()
mouseX.value = e.clientX - boundingRect.left;
mouseY.value = e.clientY - boundingRect.top;
pinia_zoom.value = zoom.value
};
const mouse_down = (e) => {
console.log(e);
if (e.button == 1) {
mouse_down_flag.value = true
}
}
const mouse_up = (e) => {
if (e.button == 1) {
mouse_down_flag.value = false
}
}
const mouse_down_flag = ref(false)
const mouse_move = (e) => {
if (mouse_down_flag.value == true) {
console.log(e);
elLeft.value += e.movementY
elTop.value += e.movementX
}
}
const elLeft = ref<number>(-675);
const elTop = ref<number>(-310);
const start_posationX = ref<number>(0);
const start_posationY = ref<number>(0);
const dragstart = (e: any) => {
console.log(e);
console.log(e.clientX);
console.log(e.clientY);
start_posationX.value = e.clientX;
start_posationY.value = e.clientY;
};
const dragend = async (e: any) => {
if (click_direction.value == false) {
elTop.value += (e.clientX * 1) - (1 * start_posationX.value);
elLeft.value += (e.clientY * 1) - (1 * start_posationY.value);
} else {
elTop.value += (e.clientX * 1) - (1 * start_posationX.value);
elLeft.value += (e.clientY * 1) - (1 * start_posationY.value);
setTimeout(() => {
project_click(click_id.value);
}, 1);
}
};
const dragenter = () => {
var outer: any = document.getElementsByClassName("videoNull");
outer = Array.from(outer);
outer.forEach(function (item: any) {
item.ondragover = dragover;
});
function dragover(event: any) {
event.preventDefault();
}
};