@khanacademy/perseus 57.2.0 → 57.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/es/index.js
CHANGED
|
@@ -28928,7 +28928,28 @@ const LockedEllipse = props => {
|
|
|
28928
28928
|
}));
|
|
28929
28929
|
};
|
|
28930
28930
|
|
|
28931
|
+
function clampDomain(domain, graphBounds) {
|
|
28932
|
+
// If the domain is invalid, return the graph bounds
|
|
28933
|
+
if (domain[0] > domain[1]) {
|
|
28934
|
+
return graphBounds;
|
|
28935
|
+
}
|
|
28936
|
+
|
|
28937
|
+
// If the domain is outside the graph bounds, return null
|
|
28938
|
+
if (domain[0] < graphBounds[0] && domain[1] < graphBounds[0] || domain[0] > graphBounds[1] && domain[1] > graphBounds[1]) {
|
|
28939
|
+
return null;
|
|
28940
|
+
}
|
|
28941
|
+
|
|
28942
|
+
// Clamp the function to the bounds of the graph to prevent memory
|
|
28943
|
+
// leaks when the domain is set to something like [-Infinity, Infinity].
|
|
28944
|
+
const min = Math.max(domain[0], graphBounds[0]);
|
|
28945
|
+
const max = Math.min(domain[1], graphBounds[1]);
|
|
28946
|
+
return [min, max];
|
|
28947
|
+
}
|
|
28948
|
+
|
|
28931
28949
|
const LockedFunction = props => {
|
|
28950
|
+
const {
|
|
28951
|
+
range
|
|
28952
|
+
} = useGraphConfig();
|
|
28932
28953
|
const [equation, setEquation] = useState();
|
|
28933
28954
|
const {
|
|
28934
28955
|
color,
|
|
@@ -28938,8 +28959,7 @@ const LockedFunction = props => {
|
|
|
28938
28959
|
} = props;
|
|
28939
28960
|
const plotProps = {
|
|
28940
28961
|
color: lockedFigureColors[color],
|
|
28941
|
-
style: strokeStyle
|
|
28942
|
-
domain
|
|
28962
|
+
style: strokeStyle
|
|
28943
28963
|
};
|
|
28944
28964
|
const hasAria = !!props.ariaLabel;
|
|
28945
28965
|
useEffect(() => {
|
|
@@ -28950,6 +28970,12 @@ const LockedFunction = props => {
|
|
|
28950
28970
|
if (typeof equation === "undefined") {
|
|
28951
28971
|
return null;
|
|
28952
28972
|
}
|
|
28973
|
+
const clampedDomain = directionalAxis === "x" ? clampDomain(domain, range[0]) : clampDomain(domain, range[1]);
|
|
28974
|
+
|
|
28975
|
+
// The domain entirely is outside the bounds of the graph. Don't render.
|
|
28976
|
+
if (clampedDomain === null) {
|
|
28977
|
+
return null;
|
|
28978
|
+
}
|
|
28953
28979
|
return /*#__PURE__*/React.createElement("g", {
|
|
28954
28980
|
className: "locked-function",
|
|
28955
28981
|
"aria-label": hasAria ? props.ariaLabel : undefined,
|
|
@@ -28958,11 +28984,13 @@ const LockedFunction = props => {
|
|
|
28958
28984
|
}, directionalAxis === "x" && /*#__PURE__*/React.createElement(Plot$2.OfX, _extends({
|
|
28959
28985
|
y: x => equation.eval({
|
|
28960
28986
|
x
|
|
28961
|
-
})
|
|
28987
|
+
}),
|
|
28988
|
+
domain: clampedDomain
|
|
28962
28989
|
}, plotProps)), directionalAxis === "y" && /*#__PURE__*/React.createElement(Plot$2.OfY, _extends({
|
|
28963
28990
|
x: y => equation.eval({
|
|
28964
28991
|
y
|
|
28965
|
-
})
|
|
28992
|
+
}),
|
|
28993
|
+
domain: clampedDomain
|
|
28966
28994
|
}, plotProps)));
|
|
28967
28995
|
};
|
|
28968
28996
|
|
|
@@ -41448,7 +41476,7 @@ const addLibraryVersionToPerseusDebug = (libraryName, libraryVersion) => {
|
|
|
41448
41476
|
|
|
41449
41477
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
41450
41478
|
const libName = "@khanacademy/perseus";
|
|
41451
|
-
const libVersion = "57.2.
|
|
41479
|
+
const libVersion = "57.2.1";
|
|
41452
41480
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
41453
41481
|
|
|
41454
41482
|
const apiVersion = {
|