metafizzy / packery

:bento: Gapless, draggable grid layouts
https://packery.metafizzy.co
4.13k stars 315 forks source link

How to rearrange many elements using Javascript? #500

Closed sakibanda closed 6 years ago

sakibanda commented 6 years ago

Hi,

I want to rearrange all packery elements using JavaScript.

Like Send Element - 5 to Postition - 1 Send Element - 10 to Postion - 2

Is there is any built-in methods to do this or is there any other easyway?

I tried many different ways but nothing is working well.

Like use Drag-Drop Simulate but its not working to re-arranging many elements as there are positioned absolute. When elements are re-positioned its not possible to get updated order of elements to target to specific position.

Like if i sent Element 5 To Position 1 Then Send Element 8 - Position 5 Its sending Element 8 To Position 1 as DOM index of 5 is still Element 5 still.

Is there any Packery method to get elements sorted by position in grid? How to solve this?

desandro commented 6 years ago

Is there any Packery method to get elements sorted by position in grid?

You could use Isotope with the Packery layout mode. Although, you cannot use drag & drop with Isotope

Otherwise, if you want to position items at certain locations, use the fit method