Muuri: Item Resize (FEATURE)

Created on 16 Jan 2020  ·  5Comments  ·  Source: haltu/muuri

Being able to resize elements within the grid.

question

All 5 comments

This is something Muuri's API can already do with little effort:

function resizeItem(item, width, height) {
  var el = item.getElement();
  var grid = item.getGrid();
  el.style.width = width + 'px';
  el.style.height = height + 'px';
  grid.refreshItems(item);
  grid.layout();
}

Here's a little more refined example with some CSS transitions (double-click the items): https://codepen.io/niklasramo/pen/eYmLQXO

If you're wishing for something like resizing by dragging the item from it's corner then you have to do the dragging part yourself. It's a bit of work, but should be pretty trivial. But the actual resizing part is as simple as the code above.

Thank you for your reply. I did refer to drag to resize. I understand if that's not in the current scope of the tool, but I thought it would be a good feature request even if for a distant future. Thank you!

@discobanco yep, thanks for the request, but I'm pretty sure this feature is best left outside Muuri's core (at least for the time being).

in case this is helpful or educational for anyone else - a little resize-able item demo ✌🏼
https://codepen.io/spencercap/pen/BaoMJVz

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bsherwoodofdaptiv picture bsherwoodofdaptiv  ·  4Comments

aljimenez2 picture aljimenez2  ·  3Comments

realsoelynn picture realsoelynn  ·  4Comments

niklasramo picture niklasramo  ·  3Comments

PrestaShark picture PrestaShark  ·  7Comments