We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f5677c5 commit df0bf5fCopy full SHA for df0bf5f
1 file changed
src/components/keep-scale/keep-scale.tsx
@@ -11,16 +11,22 @@ export const KeepScale = React.forwardRef<
11
const instance = useContext(Context);
12
13
useEffect(() => {
14
- return instance.onChange((ctx) => {
+ const applyScale = (scale: number) => {
15
if (localRef.current) {
16
const positionX = 0;
17
const positionY = 0;
18
localRef.current.style.transform = instance.handleTransformStyles(
19
positionX,
20
positionY,
21
- 1 / ctx.instance.transformState.scale,
+ 1 / scale,
22
);
23
}
24
+ };
25
+
26
+ applyScale(instance.transformState.scale);
27
28
+ return instance.onChange((ctx) => {
29
+ applyScale(ctx.instance.transformState.scale);
30
});
31
}, [instance]);
32
0 commit comments