简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM