I have packery with jQuery Draggable all setup and working correctly on my development environment.
At the moment I am saving my ordered (packery) html to the database. Before everything is inserted to the DB I change the order of the dom elements to match the packery order. Everything works nicely
when re-loading the page with the saved html all the divs appear in their position as per the save.
The problem I am having is when I set up packery again with my loaded HTML using ($grid is the parent div)
var $grid = $('.grid');
$grid.packery({
columnWidth: '.grid-sizer',
itemSelector: '.grid-item',
stamp: ".stamp",
gutter:0,
percentPosition: true
});
Packery does its thing a "packs" everything again. which is exactly what it is supposed to do. Thing is i want to keep my old layout that may of had empty space in it.
My question is...
Is it possible to init packery without triggering the layout function? I have tried adding initLayout: false to the options. but it doesn't let me drag elements & layoutInstant: false doesn't seem to do anything.
Screens of saved html (after dragging everything how i want it) and then after re-loading and then $grid.packery()
https://i.stack.imgur.com/fS2Vp.png
https://i.stack.imgur.com/pAnkW.png
Alright i managed to sort this out myself. mainly from this answer on the metafizzy git metafizzy isse tracker
Added code before the initial packery set up
When setting packery up. set
initLayout:falsee.g.Then setting everything up (data-item-index) is a unique value added to each div that can be moved around. you could use 'id'