Set drag limit at T-shirt or another product . I use fabric.js with nextjs
Unanswered
Iridescent shark posted this in #help-forum
Iridescent sharkOP
function addTShirtImage(url: string) {
fabric.Image.fromURL(url, (img) => {
const imgWidth = canvasWidth;
const imgHeight = canvasHeight;
img.set({
left: 0,
top: 0,
selectable: false,
hasControls: false,
evented: false,
});
canvas.setBackgroundImage(img, canvas.renderAll.bind(canvas));
const designArea = new fabric.Rect({
left: canvasWidth * 0.27,
top: canvasHeight * 0.2,
width: canvasWidth * 0.5,
height: canvasHeight * 0.5,
fill: "transparent",
stroke: "#000000",
strokeDashArray: [5, 5],
selectable: false,
evented: false,
});
canvas.add(designArea);
saveState();
});
}
fabric.Image.fromURL(url, (img) => {
const imgWidth = canvasWidth;
const imgHeight = canvasHeight;
img.set({
left: 0,
top: 0,
selectable: false,
hasControls: false,
evented: false,
});
canvas.setBackgroundImage(img, canvas.renderAll.bind(canvas));
const designArea = new fabric.Rect({
left: canvasWidth * 0.27,
top: canvasHeight * 0.2,
width: canvasWidth * 0.5,
height: canvasHeight * 0.5,
fill: "transparent",
stroke: "#000000",
strokeDashArray: [5, 5],
selectable: false,
evented: false,
});
canvas.add(designArea);
saveState();
});
}