Dependent gliders: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
Line 8: | Line 8: | ||
var C = brd.create('glider', [ 3,-1,li]); | var C = brd.create('glider', [ 3,-1,li]); | ||
brd.addHook(function() { | brd.addHook(function() { | ||
if (brd.mouse.obj==A) { | if (brd.mouse.obj==A || brd.touches[0].obj==A) { | ||
B.position = A.position - 0.3; | B.position = A.position - 0.3; | ||
B.prepareUpdate().update(true).updateRenderer(); | B.prepareUpdate().update(true).updateRenderer(); | ||
Line 14: | Line 14: | ||
C.setPositionDirectly(JXG.COORDS_BY_USER, A.X()+3, C.Y()); | C.setPositionDirectly(JXG.COORDS_BY_USER, A.X()+3, C.Y()); | ||
C.prepareUpdate().update().updateRenderer(); | C.prepareUpdate().update().updateRenderer(); | ||
} else if (brd.mouse.obj==B) { | } else if (brd.mouse.obj==B || brd.touches[0].obj==B) { | ||
A.position = B.position + 0.3; | A.position = B.position + 0.3; | ||
A.prepareUpdate().update(true).updateRenderer(); | A.prepareUpdate().update(true).updateRenderer(); | ||
Line 20: | Line 20: | ||
C.setPositionDirectly(JXG.COORDS_BY_USER, A.X()+3, C.Y()); | C.setPositionDirectly(JXG.COORDS_BY_USER, A.X()+3, C.Y()); | ||
C.prepareUpdate().update().updateRenderer(); | C.prepareUpdate().update().updateRenderer(); | ||
} else if (brd.mouse.obj==C) { | } else if (brd.mouse.obj==C || brd.touches[0].obj==C) { | ||
A.setPositionDirectly(JXG.COORDS_BY_USER, C.X()-3, A.Y()); | A.setPositionDirectly(JXG.COORDS_BY_USER, C.X()-3, A.Y()); | ||
A.prepareUpdate().update().updateRenderer(); | A.prepareUpdate().update().updateRenderer(); |