2023-10-02 20:29:26 +02:00
|
|
|
import { useGridItemRef } from '../item/context';
|
|
|
|
|
import { useGridstackRef } from './context';
|
|
|
|
|
|
|
|
|
|
type ResizeGridItemProps = {
|
|
|
|
|
height: number;
|
|
|
|
|
width: number;
|
|
|
|
|
x: number;
|
|
|
|
|
y: number;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const useResizeGridItem = () => {
|
|
|
|
|
const itemRef = useGridItemRef();
|
|
|
|
|
const gridstackRef = useGridstackRef();
|
|
|
|
|
|
|
|
|
|
return ({ height, width, ...options }: ResizeGridItemProps) => {
|
2023-10-09 06:30:43 +02:00
|
|
|
if (!itemRef?.current) return;
|
2023-10-08 21:00:10 +02:00
|
|
|
gridstackRef?.current?.update(itemRef.current!, {
|
2023-10-02 20:29:26 +02:00
|
|
|
...options,
|
|
|
|
|
h: height,
|
|
|
|
|
w: width,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
};
|