문제

considering this basic case, one may expect the coordinates of the layer to be updated... but they would not.

Instead, there is the possibility of remembering the starting point, compute the mouse offset and then update the coordinates, like in this test but... the effect is quite extreme. Expected : point x1,y1 is static Result : point x1,y1 moves incredibly fast

If setting coordinates to constant, the drag remains the same. The main problem here is that drag action applies to the whole layer.

Fix : apply the modification at the end of the drag, like in this snippet. But it is relatively ugly. Anyone has a better way to

  • get on the run the actual coordinates of the points of the line
  • manage to keep a point of the line static while the others are moving

Looking forward your suggestions,

도움이 되었습니까?

해결책

In order to maintain the efficiency of dragging layers, jCanvas only offsets the x and y properties for any draggable layer (including paths). Therefore, when dragging, you can compute the absolute positions of any set of path coordinates using something along these lines:

var absX1 = layer.x + layer.x1;
var absY1 = layer.y + layer.y1;

(assuming layer references a jCanvas layer, of course)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top