Insert and reposition flow
What is sort dispersion in Gridifier?
Sort dispersion defines, how far from valid insertion position/positions next inserted/repositioned item
can be placed.
var grid = new Gridifier(demoGrid, {
// By default, sort dispersion is disabled.(items are inserted in normal flow)
sortDispersion: false|true
});
What those values means?
- false
- all items are inserted/repositioned in normal flow, so
item cannot be 'placed' outside it's valid position.
- true
- next inserted/repositioned item can be 'placed' anywhere in empty grid space.
(out of normal flow)
What is valid item position? (normal flow)
- on vertical grid appends
- next item cannot be inserted above any of already inserted items.
- on vertical grid prepends
- next item cannot be inserted below any of already inserted items.
- on horizontal grid appends
- next item cannot be inserted before any of already inserted items.
- on horizontal grid prepends
- next item cannot be inserted behind any of already inserted items.
- on mirrored prepends
- append rules will be applied.
What is valid item coords? (in normal flow)
- on vertical grid appends
- next item Y2 should be >= Y1 of all already inserted items.
- on vertical grid prepends
- next item Y1 should be <= Y2 of all already inserted items.
- on horizontal grid appends
- next item X2 should be >= X1 of all already inserted items.
- on horizontal grid prepends
- next item X1 should be <= X2 of all already inserted items.
In which cases each of modes is more preferable?
- false
- order of inserted(filtered/sorted) items is important. Grid should always
retain it, even if there are some empty space when items with different sizes are used.
- true
- order of inserted(filtered/sorted) items is not fixed. Any inserted item can be
placed anywhere in empty grid space.(where it can fit)
Reposition flow notices
The one more important thing to notice is that with disabled sort dispersion Gridifier is
assigning insertion number(GUID) to each inserted item. Thus, on viewport/custom grid resizes
items will be collected retaining GUIDS order, so initial items order will never break.
Alternatively, with enabled sort dispersion modes no GUIDS are assigned, so Gridifier
is collecting items based on they position and append type. For example, with default append type
and vertical grid items will be collected starting from left top corner by min Y to the right.
So, it is correctly to admit that with enabled sort dispersion each grid item is tied
to its insertion coords instead of insertion order.
Sort dispersion demo grid:
Sort dispersion:
Controls:
sortDispersion setting
defines inserted/repositioned items insert flow type
available values = false, true; default = false
next: Repack sorts
prev: Filters