From bbc272451d540e6bc1c0769e3e432bd41cf97ea6 Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Mon, 13 Jun 2022 11:40:32 -0500 Subject: [PATCH] Fix the prevention of creating degenerate objects with keyboard controls. When graphing a parabola (via any of the tools that do so) or a cubic it is possible to create degenerate objects. The code that is supposed to prevent that wasn't quite working right. The jsxgraph board object needs to be updated after setting the position of a point programatically. To test this graph any of those objects and then move one of the defining points of the object around with the keyboard. For example, graph a three point quadratic and try to move one point onto the same vertical line as another point. That should not be possible. --- htdocs/js/apps/GraphTool/cubictool.js | 1 + htdocs/js/apps/GraphTool/graphtool.js | 1 + htdocs/js/apps/GraphTool/quadratictool.js | 1 + 3 files changed, 3 insertions(+) diff --git a/htdocs/js/apps/GraphTool/cubictool.js b/htdocs/js/apps/GraphTool/cubictool.js index a07f026580..b059f9724a 100644 --- a/htdocs/js/apps/GraphTool/cubictool.js +++ b/htdocs/js/apps/GraphTool/cubictool.js @@ -38,6 +38,7 @@ } el.setPosition(JXG.COORDS_BY_USER, [x, el.Y()]); + gt.board.update(); } }, diff --git a/htdocs/js/apps/GraphTool/graphtool.js b/htdocs/js/apps/GraphTool/graphtool.js index e76d02063a..4bd6f88b62 100644 --- a/htdocs/js/apps/GraphTool/graphtool.js +++ b/htdocs/js/apps/GraphTool/graphtool.js @@ -452,6 +452,7 @@ window.graphTool = (containerId, options) => { else if (y > boundingBox[1]) y = boundingBox[1] - gt.snapSizeY; point1.setPosition(JXG.COORDS_BY_USER, [x, y]); + gt.board.update(); }; // Prevent paired points from being moved into the same position by a drag. This diff --git a/htdocs/js/apps/GraphTool/quadratictool.js b/htdocs/js/apps/GraphTool/quadratictool.js index 8b7530dc50..a487077b6e 100644 --- a/htdocs/js/apps/GraphTool/quadratictool.js +++ b/htdocs/js/apps/GraphTool/quadratictool.js @@ -38,6 +38,7 @@ } el.setPosition(JXG.COORDS_BY_USER, [x, el.Y()]); + gt.board.update(); } },