Closed wavetydesigns closed 11 years ago
Wow. I would love to see that in action. I didn't design the plugin to be compatible with jQuery UI. In fact, it might actually be designed to break it. I'm pretty impressed if you pulled it off.
Here is a sample I setup for you. Again, tested in the 3 browsers I mentioned above. Hopefully this will help you in testing your plug-in, as you can get real-time feedback on how it sorts when boxes move/resize.
http://tyler-designs.com/masonry-ui/
My use may not fit what everyone needs the plug-in for, but it worked well for what I needed so I am using it on my site currently just like this.
Sorry to say that I do not believe masonry layout is actually working. The smaller boxes should fit inside all that empty space
I can't quite see the order list below the boxes on your screenie, but I tried to duplicate it and it works for me. Can I ask what browser you used?
*Edit, I was able to duplicate your screenie. So, I'm assuming its not working to its fullest. Because I feel like its definitely working at times. If you look at my sample again, I've placed a standard sortable/resizable (with float:left) next to the masonry'd one. There is a huge difference in how it reacts, so I'm curious as to what is being missed by it.
After playing around with it a bit more, I'm happy to say that indeed it works. My only concern is that the drag n drop interaction is not intuitive as one would expect. The layout algorithm that Masonry uses isn't a general top-down / left-right direction, so sometimes when you pull a box over to a new spot, it appears where you didn't expect it.
Regardless, this is a commendable acheivement. Thanks so much for pushing the capabilities of the plugin :)
I am trying to do the same thing (use masonry for positioning, but allow user to rearrange). However, the demo you show is not working for me. Is there something that changed? Desandro, is there any plans for sortable/draggable support in masonry?
Dragging will continue be unsupported in Masonry.
The closest solution is the jQuery Sortable widget - Grid
Seems like there is a big enough demand for drag-n-droppable Masonry. From the developer's perspective, Masonry's layout algorithm cannot be reverse engineered to support this feature. I have considered building a separate draggable grid plugin - but that's for another day.
Oh. Yeah, that css float is what I started with before Masonry, but I need to support multiple heights. Thanks.
I'm thinking about just having a "move up" and "move down" buttons for each object that would then refresh the Masonry after moving the item up or down in the DOM. Not quite as elegant as dragging and dropping, but would be able to work without any plugin hacking.
hi, the problem of using label instead of
is that label is not auto resizeable (it will not fit to the box).. right?Hi,
I was able to get away with adding drag and drop to masonry in a fairly good manner. But the layout is simpler than the proposed test page here.
Anyway I was able, out of box to improve performance a bit, mostly by using change instead of sort. Cutting and pasting the core code:
init: function ()
{
cards.list.all.addClass('layout-card');
cards.makeSortable(groups.list.all.children('.cards'));
cards.applyMasonry(groups.list.all.children('.cards'));
},
applyMasonry: function (t)
{
t.masonry({
itemSelector: '.layout-card',
isResizable: true
})
},
makeSortable: function (t)
{
t.sortable({
distance: 12,
forcePlaceholderSize: true,
items: '.layout-card',
placeholder: 'card-sortable-placeholder layout-card',
tolerance: 'pointer',
start: function(event, ui) {
ui.item.addClass('dragging').removeClass('layout-card');
ui.item.parent().masonry('reload')
},
change: function(event, ui) {
ui.item.parent().masonry('reload');
},
stop: function(event, ui) {
ui.item.removeClass('dragging').addClass('layout-card');
ui.item.parent().masonry('reload');
},
});
}
The code/app should go live in the next few days, if anyone is interested I can buzz you later ;)
I'd personally love to see this as I've put my project on hold for a bit, so could still use a solution.
@miguelfatia's solution worked great for me in a two-column layout where all the items have a fixed with. The ordering gets a little unpredictable when you have more than two columns but it works pretty well even then.
The release is expected next week, but everything will be compressed so I have created a jsfiddle with a quick demo ;)
On the order tidbit, I agree, but then again Masonry by itself already shuffles things a bit. My main interest is/was visual coherence.
cheers!
Iiiiinnnnnnnnteresting. It sorta kinda works with a brick that spans two columns as well
@miguelfatia Thanks for the solution!
Hi David,
I'm know you slammed, but would be awesome if you could knock out a drag and drop grid framework.
Franklin
@franklinwise Probably not going to happen for a while. See http://metafizzy.co/blog/mythical-drag-drop-multi-column-grid-plugin/
Thanks for the response David.
here's my attempt
Edit: consider this a POC. It has a tone of problems atm.
@icholy You made it! I'll work on your solution!
slightly smarter version http://jsfiddle.net/qU2KW/
Edit: If you don't see the difference, it's because the old fiddle is also running the newer version.
Just added a brick 'ghosting' feature so if you hover over a spot without dropping you get a ghost showing you where it will be placed.
Hi there,
thanks for this, simply awsome.
I am a newb. That said, i am struggling to make this work with infinite scroll. It works for my first page, but not for any element loaded by infinite scroll.
reloading masonry for new infinite scroll elements like this: $container.masonry( 'appended', $newElems, true );
shouldnt this trigger masonry as defined before the infinite scrol (with your params isDraggable : true, dragHandleSelector: '.handle', dragClass: 'dragging')
??
Any hint really appreciated.
many thx.
Packery is out http://packery.metafizzy.co It has support for draggable interactions
Packery is a JavaScript layout library that uses a bin-packing algorithm. This is a fancy way of saying “it fills empty gaps.”
Masonry will most likely never support draggable interactions. Please use Packery instead. We can now close this issue forever.
:fireworks: :cake: :gift_heart: :grey_exclamation: :sailboat: :beers: :cake: :gift_heart: :grey_exclamation: :sailboat: :beers: :fireworks: :gift_heart: :grey_exclamation: :sailboat: :beers: :fireworks: :cake: :grey_exclamation: :sailboat: :beers: :fireworks: :cake: :gift_heart: :sailboat: :beers: :fireworks: :cake: :gift_heart: :grey_exclamation: :beers: :fireworks: :cake: :gift_heart: :grey_exclamation: :sailboat:
jQuery Shapeshift is a great alternative, draggable masonry layouts
I've been able to get masonry working with jquery.ui.sortable and jquery.ui.resizeable all at the same time.
In my case, it required the following:
No changes to the actual code was needed.
*Tested in Chrome (fast - no performance hit), IE8 (slow, but works), Firefox (fast)