vaheqelyan / svelte-grid

A responsive, draggable and resizable grid layout, for Svelte.
https://svelte-grid.now.sh/
MIT License
948 stars 57 forks source link

updated add_remove.svx by adding reducer to function add to set item responsiveness #81

Closed frantic0 closed 3 years ago

frantic0 commented 3 years ago

for all layout column configurations

e.g.

if you have

  let cols = [
    [2880, 12],
    [1600, 12],
    [1280, 8], // over this rez is failling
    [1024, 6],
    [800, 3],
    [500, 2]
  ];

sets all COL props to the new item to add

vaheqelyan commented 3 years ago

Have you tried adding more columns ?

const cols = [[1100, 6], [300, 4]];

I tried adding some more columns and it gave an error

matrix.js:3 Uncaught RangeError: Invalid array length
    at makeMatrix (matrix.js:3)
    at makeMatrixFromItems (matrix.js:6)
    at Object.findSpace (helper.js:37)
    at add_remove.svx:52
    at Array.reduce (<anonymous>)
    at HTMLButtonElement.add (add_remove.svx:49)

https://github.com/vaheqelyan/svelte-grid/blob/master/src/utils/helper.js#L37 getRowsCount(items, cols) returns NaN

vaheqelyan commented 3 years ago

The thing is, I am using a 2d array to find the position for an element https://github.com/vaheqelyan/svelte-grid/blob/master/src/utils/matrix.js#L6 After this line

if(!_row) return matrix

Adding this line to utils/matrix.js- fixes the error (hardcoded)