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. | var o; | ||
if (typeof brd.touches != 'undefined && brd.touches.length>0) { | |||
o = brd.touches[0].obj; | |||
} else if (typeof brd.mouse.obj != 'undefined') { | |||
o = brd.mouse.obj; | |||
} else { | |||
return; | |||
} | |||
if (o==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 23: | ||
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 ( | } else if (o==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 29: | ||
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 ( | } else if (o==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(); |