Dinesh Ramasamy
Dinesh Ramasamy

Reputation: 994

How to move both objects which has same point, at the same time in JSXGraph?

// Created an arrow providing two points.

var A = board.create('point', [4.0, 2.0]);
var B = board.create('point', [1.0, 1.0]);
board.create('arrow', [A, B]);

// Created a line providing two points.

var C = board.create('point', [4.0, 2.0]);
var D = board.create('point', [6.0, 2.0]);
board.create('line', [C, D]);

Now both point A and C are same. When I move it, only C gets moved as it was created at last. Is there any chance of moving both objects(arrow & line) together when the common point(A,C) is moved?

Upvotes: 1

Views: 305

Answers (1)

Alfred Wassermann
Alfred Wassermann

Reputation: 2323

There is the possibility to glue the two points A and C together. To be precise, one can set C to be a "glider" on A.

var A = board.create('point', [4.0, 2.0]);
var B = board.create('point', [1.0, 1.0]);
board.create('arrow', [A, B]);

var C = board.create('point', [4.0, 2.0]);
var D = board.create('point', [6.0, 2.0]);
board.create('line', [C, D]);

C.makeGlider(A).setProperty({fixed: true});
board.update();

It is necessary to set fixed:true for C. Otherwise C would get the focus when dragging. But dragging a glider which lives on a point makes no sense.

Upvotes: 4

Related Questions