svelte-grid
svelte-grid copied to clipboard
Freeze and unfreeze grid
I don't see a way to freeze and unfreeze the grid, meaning that all items should become fixed, not draggable or scalable.
I wrote a rather dirty workaround:
const toggleFreeze = (shouldFreeze) => {
for(let item of items){
for(let key in item){
if(typeof(item[key].fixed) === 'boolean' ){
item[key].fixed = !!shouldFreeze;
item[key].resizable = !!shouldFreeze;
item[key].draggable = !!shouldFreeze;
}
}
}
}
but it has one caveat. After toggling the grid needs to update in order to change to fixed elements, which I don't know how to trigger within the code. So it waits until some user action to take effect.
Is there any other way to freeze the grid and unfreeze it if necessary?
check this https://svelte.dev/repl/a908ae0c59ad421cb9d9bc37503f07ef?version=3.53.1
i think the way you update your items
does not trigger reactivity