Restrict points to limited area: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
Line 2: | Line 2: | ||
var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-5,5,5,-5], axis:true}); | var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-5,5,5,-5], axis:true}); | ||
var A = brd.create('point', [-1,-1], {name:'A'}); | var A = brd.create('point', [-1,-1], {name:'A'}); | ||
var B = brd.create('point', [-3, | var B = brd.create('point', [-3, -3], {name:'B'}); | ||
var C = brd.create('point', [ | var C = brd.create('point', [ -2, 0], {name:'C'}); | ||
brd.on('move', function() { | brd.on('move', function() { | ||
var list = [A, B, C], i; | var list = [A, B, C], i; | ||
brd.suspendUpdate(); | |||
for (i = 0; i < list.length; ++i) { | for (i = 0; i < list.length; ++i) { | ||
list[i].moveTo([Math.min(0, list[i].X()), Math.min(0, list[i].Y())]); | list[i].moveTo( | ||
[ | |||
Math.min(0, list[i].X()), | |||
Math.min(0, list[i].Y()) | |||
] | |||
); | |||
} | } | ||
brd.unsuspendUpdate(); | |||
}); | }); | ||
Line 18: | Line 25: | ||
===The underlying JavaScript code=== | ===The underlying JavaScript code=== | ||
<source lang="javascript"> | <source lang="javascript"> | ||
</source> | </source> | ||
[[Category:Examples]] | [[Category:Examples]] |