diff --git a/src/components/stories/04-testing/Testing.stories.mdx b/src/components/stories/04-testing/Testing.stories.mdx
index b3343b5..25c1425 100644
--- a/src/components/stories/04-testing/Testing.stories.mdx
+++ b/src/components/stories/04-testing/Testing.stories.mdx
@@ -1,5 +1,5 @@
import { Meta, Story, Canvas, Props } from "@storybook/addon-docs";
-import { StateDriven, AnchoredDefaultOrdering, SpaceDemoStacked1 } from "../Utils";
+import { StateDriven, AnchoredDefaultOrdering, SpaceDemoStacked1, StateDrivenSize } from "../Utils";
@@ -19,4 +19,10 @@ import { StateDriven, AnchoredDefaultOrdering, SpaceDemoStacked1 } from "../Util
+
+
+
\ No newline at end of file
diff --git a/src/components/stories/Utils.tsx b/src/components/stories/Utils.tsx
index 5ab25a6..642c6a7 100644
--- a/src/components/stories/Utils.tsx
+++ b/src/components/stories/Utils.tsx
@@ -323,6 +323,16 @@ export const StateDriven: React.FC = () => {
);
};
+export const StateDrivenSize = () => {
+ const [size, setSize] = React.useState(250);
+ return (
+
+ setSize(s)}>
+
+
+ );
+};
+
export const AnchoredDefaultOrdering = () => {
return (
diff --git a/src/core-resizing.ts b/src/core-resizing.ts
index 3c6fb5d..cb0eee6 100644
--- a/src/core-resizing.ts
+++ b/src/core-resizing.ts
@@ -148,20 +148,33 @@ export function createResize(store: ISpaceStore) {
e.preventDefault();
if (RESIZE_THROTTLE > 0) {
- throttle((x, y) => window.requestAnimationFrame(() => resize(x, y)), RESIZE_THROTTLE)(lastX, lastY);
+ throttle(
+ (x, y) =>
+ window.requestAnimationFrame(() => {
+ if (space.resizing) {
+ resize(x, y);
+ }
+ }),
+ RESIZE_THROTTLE,
+ )(lastX, lastY);
} else {
- window.requestAnimationFrame(() => resize(lastX, lastY));
+ window.requestAnimationFrame(() => {
+ if (space.resizing) {
+ resize(lastX, lastY);
+ }
+ });
}
};
const removeListener = () => {
+ space.resizing = false;
+
if (moved) {
resize(lastX, lastY);
}
+
window.removeEventListener(moveEvent, withPreventDefault as EventListener);
window.removeEventListener(endEvent, removeListener);
-
- space.resizing = false;
space.updateParent();
const resizeEnd = onResizeEnd || space.onResizeEnd;