door_models 5.3.5 → 5.3.6

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/index.esm.js CHANGED
@@ -1458,7 +1458,24 @@ function DoorModels(_ref7) {
1458
1458
  secondDoorStopWidth,
1459
1459
  secondDoorStopDepth
1460
1460
  } = doorFrame;
1461
- const initialDoorHeight = useRef(doorHeight);
1461
+ const initialDoorHeight = useRef(null);
1462
+ useEffect(() => {
1463
+ // If our initial height hasn't been set yet AND we have a valid height...
1464
+ if (initialDoorHeight.current === null && doorHeight > 0) {
1465
+ // ...set it. This will now be the stable base value for your logic.
1466
+ // This line will only run once for the initial valid height.
1467
+ initialDoorHeight.current = doorHeight;
1468
+ }
1469
+ }, [doorHeight]); // This hook listens for changes to doorHeight
1470
+
1471
+ // YOUR ORIGINAL LOGIC IS UNCHANGED, we just add a safety check.
1472
+ const pivotNewPosition = useMemo(() => {
1473
+ // If the initial value hasn't been captured, don't move the door.
1474
+ if (initialDoorHeight.current === null || initialDoorHeight.current === 0) return 0;
1475
+
1476
+ // Your existing, correct logic now works because initialDoorHeight.current is correct.
1477
+ return (doorHeight - initialDoorHeight.current) / 2 / 1000;
1478
+ }, [doorHeight]);
1462
1479
  const {
1463
1480
  height: interiorFanlightHeightValue
1464
1481
  } = interiorFanlight;
@@ -1530,10 +1547,6 @@ function DoorModels(_ref7) {
1530
1547
  x: 0
1531
1548
  }];
1532
1549
  }, [isDoubleDoor, doorWidthM, doorPivot]);
1533
- const pivotNewPosition = useMemo(() => {
1534
- if (!initialDoorHeight.current || initialDoorHeight.current === 0) return 0;
1535
- return (doorHeight - initialDoorHeight.current) / 2 / 1000;
1536
- }, [doorHeight]);
1537
1550
 
1538
1551
  // --- Centering & Positioning ---
1539
1552
  const yCenteringOffset = -topFrameWidthM / 2;
@@ -1893,8 +1906,7 @@ function DoorLeaf(_ref8) {
1893
1906
  doorWidth,
1894
1907
  doorHeight,
1895
1908
  theDoorDepth,
1896
- doorOpening,
1897
- doorName
1909
+ doorOpening
1898
1910
  } = door;
1899
1911
  const {
1900
1912
  frameDepth,
@@ -1909,19 +1921,10 @@ function DoorLeaf(_ref8) {
1909
1921
  } = doorFrame;
1910
1922
  const initialDoorHeight = useRef(null);
1911
1923
  useEffect(() => {
1912
- initialDoorHeight.current = null;
1913
- }, [doorName]);
1914
- useEffect(() => {
1915
- if (initialDoorHeight.current === null && doorHeight > 0) {
1924
+ if (doorHeight > 0 && initialDoorHeight.current === null) {
1916
1925
  initialDoorHeight.current = doorHeight;
1917
1926
  }
1918
1927
  }, [doorHeight]);
1919
- useMemo(() => {
1920
- if (initialDoorHeight.current === null) {
1921
- return 0;
1922
- }
1923
- return (doorHeight - initialDoorHeight.current) / 2 / 1000;
1924
- }, [doorHeight]);
1925
1928
  const {
1926
1929
  x1: occulusX1,
1927
1930
  x2: occulusX2,