1
개체를 이동할 때. "수정 된"이벤트에서 그리드 바깥으로 오브젝트를 이동하지 않았는지 확인합니다. 만약 그렇다면, 객체를 초기 좌표로 되돌립니다. 오른쪽으로 돌아갑니다. 그러나 내가 그것을 다시 움직이려고 할 때. 나는 그것을 끌 수 없습니다. 시각적 인 좌표가 업데이트 된 것처럼 보입니다. 하지만 일부 충돌 좌표가 아닙니다.이 대화 형 레이어 좌표를 업데이트하는 방법은 무엇입니까?"수정 된"이벤트의 좌표 변경
canvas.on({
'object:moving': function(e) {
e.target.opacity = 0.5;
canvas.renderAll();
},
'object:modified': function(e) {
e.target.opacity = 1;
//e.target.left = 10;
var nx = Math.floor((e.target.left - offset)/60);
var ny = Math.floor((e.target.top - offset)/60);
if(nx > 4 || nx < 0 || ny > 4 || ny < 0)
{
nx = e.target.ix;
ny = e.target.iy;
}
e.target.ix = nx;
e.target.iy = ny;
//e.target.set('top', offset + 30+e.target.iy*60);
//e.target.set('left', offset + 30+e.target.ix*60);
e.target.set('top', offset + 30+ny*60);
e.target.set('left', offset + 30+nx*60);
canvas.renderAll();
}
});