mirror of
https://github.com/ajnart/homarr.git
synced 2026-02-03 13:19:17 +01:00
25 lines
584 B
TypeScript
25 lines
584 B
TypeScript
|
|
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) => {
|
||
|
|
gridstackRef.current?.batchUpdate();
|
||
|
|
gridstackRef.current?.update(itemRef.current!, {
|
||
|
|
...options,
|
||
|
|
h: height,
|
||
|
|
w: width,
|
||
|
|
});
|
||
|
|
gridstackRef.current?.batchUpdate(false);
|
||
|
|
};
|
||
|
|
};
|