Fix layout of newly added Widgets
This commit is contained in:
@@ -40,7 +40,10 @@ export default function Home({...props}) {
|
|||||||
beginEditIfNeeded(); // Save state before anything else
|
beginEditIfNeeded(); // Save state before anything else
|
||||||
|
|
||||||
const newID = uuid(); // could be replaced with something else like guid
|
const newID = uuid(); // could be replaced with something else like guid
|
||||||
|
const COLS = 16;
|
||||||
|
const W = w ?? 3;
|
||||||
|
const H = h ?? 3;
|
||||||
|
|
||||||
setWidgetArray([ // updating widget array containing info on the types of widgets
|
setWidgetArray([ // updating widget array containing info on the types of widgets
|
||||||
...widgetArray,
|
...widgetArray,
|
||||||
{i: newID, widget: name }
|
{i: newID, widget: name }
|
||||||
@@ -51,8 +54,10 @@ export default function Home({...props}) {
|
|||||||
...prev,
|
...prev,
|
||||||
{
|
{
|
||||||
i: newID,
|
i: newID,
|
||||||
x: (prev.length * 3) % 12,
|
// x: (prev.length * 3) % 12,
|
||||||
y: Infinity,
|
// y: Infinity,
|
||||||
|
x: (prev.length * W) % COLS,
|
||||||
|
y: 0,
|
||||||
w: w,
|
w: w,
|
||||||
h: h,
|
h: h,
|
||||||
minW: minw,
|
minW: minw,
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ export default function MyDashboard({layout, onLayoutChange, isEditable, isDelet
|
|||||||
useCSSTransforms={false} // remove the sliding animation of the widgets
|
useCSSTransforms={false} // remove the sliding animation of the widgets
|
||||||
className="layout"
|
className="layout"
|
||||||
layout={layout}
|
layout={layout}
|
||||||
cols={15} // Total columns in grid
|
cols={16} // Total columns in grid
|
||||||
rowHeight={30} // Height of a single row in px
|
rowHeight={30} // Height of a single row in px
|
||||||
isBounded={true} // Total width of the grid
|
isBounded={true} // Total width of the grid
|
||||||
margin={[15, 5]} // [horizontal, vertical] gap
|
margin={[15, 5]} // [horizontal, vertical] gap
|
||||||
|
|||||||
Reference in New Issue
Block a user