3

I want to force a grid item to always be in the last position even after moving items around.

I am thinking a good approach would be to

//get the total number of items
var totalItems = $('.grid-item').length; 

//adjust the .last item to be the last item in the array ????
$('.last') grid order is totalItems + 1 

//layout items again
$grid.packery('layout');

..and execute that after a change is made.

I have created a fiddle which is complete except for the magic to make the order update: https://jsfiddle.net/2buqd4nu/

I would be happy to accept any other approach that would achieve the same effect.

c01gat3
  • 597
  • 3
  • 18

1 Answers1

0

The built in "append" method does, quote:

Adds and lays out newly appended item elements to the end of the layout.

More info: https://packery.metafizzy.co/methods.html#appended

If you want even more power over the array and are not afraid of chopping up the Packery file, you can call up the elems array. See: https://packery.metafizzy.co/methods.html#getitemelements.

Hoping this helps!

Parapluie
  • 714
  • 1
  • 7
  • 22