mirror of
https://github.com/ajnart/homarr.git
synced 2026-01-15 20:12:18 +01:00
✨ Add client side removing of items, Add item position modal
This commit is contained in:
24
src/components/Board/gridstack/useResizeGridItem.ts
Normal file
24
src/components/Board/gridstack/useResizeGridItem.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
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);
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user