-
Notifications
You must be signed in to change notification settings - Fork 241
"Balanced columns" algorithm #70
base: master
Are you sure you want to change the base?
Conversation
|
||
grid.appendChild(columnsFragment); | ||
self.append_elements(grid, Array.prototype.slice.call(items.children)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid redundancy, here I just change the code to use append_elements method too.
Thank you @MoOx, this is fantastic. What if we execute the balance algorithm once the window is completely loaded though? That way we don't need to predict the image heights. |
Also would like to see a live example + any additional instructions to put it on the website. This is gonna be great! |
The problem to wait until window load is that can be long. For me you example pages take like 20secondes to load, so initiating or updating salvatorre will be really weird after that delay. I don't think it should be the default option. But you can still make |
The lack of this feature has kept me from using Salvattore, so this is really interesting. But I can't get it to run smoothly, do you have a live demo? It randomly fails for me in Chrome and Firefox. And it dosen't work at all in Safari. |
@michaelnie Grab the zip of my branch (https://github.com/MoOx/salvattore/archive/master.zip) & just try to open the |
Would just like to drop in and say I'd love this to be merged with master! 😄 On Tumblr/WordPress/etc. themes with posts that can vary wildly in height, this would improve how Salvattore presents posts dramatically. So, yeah, +1. |
Can we expose the balance Iirc, |
@mikedidthis if you use my branch ( |
I totally agree. |
Sorry for the delay! Was on vacation. I will merge this in the coming days and yes @mikedidthis, that would be very much appreciated! Thank you. |
Sorry to bother @MoOx, but I cannot make this algorithm work locally after downloading the .zip of your repo as instructed (in fact, it wouldn't even load at all in my Safari browser). I need to see a live example working in order to merge, please. |
k I will take a look. |
@rnmp Cool. Once the merge is sorted, I will expose the methods. |
@rnmp Just pushed a fix for Safari \o/ |
Exciting! Will review soon. |
Is there any news on this PR? |
let me rebase on latest change so @rnmp can merge that. |
This commit include a new algorithm that handle elements height during the repartition of the items. The previous algorithm was pretty simple (just balance same amount of items in each columns), and this can create visual issue if lots of items have different heights. I currently have an implementation that can use more than 5000 items, & with this amount the differences are too big. Checkout an  Here is a new algorithm that include a small process to retrieve correct height (by appending them in a additional column showing/retrieving value/removing ). Using a wrapper to append & remove from the dom make this very fast. I don’t get any lag with lots of items on my current board. Should close #4 (& so close #52 )
That issue was spotted on Safari 7
Rebase, so this should be ok now. |
This works well for me. The PR has stalled a bit, and I'd like to use it. So in the meantime, I've added |
Any news on this? |
I'm tired of rebasing all the time, so @rnmp should just tell me when he is open to use a "less bad" algorithm... |
Sorry @MoOx :( I do appreciate the effort you put in tho. I'm using your repo at the moment. It's almost perfect for me. Recreation works great when the images have loaded but on initial load because the images haven't loaded yet it falls back to the old way. Looking at changing up your code a bit to add a data-height to work out the calculation. |
Hey everyone! I'm deeply sorry for the lack of dedication to this project. @benjibee, I really appreciate all the attention and use that Salvattore receives. Even though this is my project, it is @ppold who is in charge of most of the code and he's very busy lately—so am I. That said, because I believe all what has been said is true, if you guys can find a way of making the automatic pull request work I'm more than willing to approve it. cc @MoOx. Also, @MoOx @attila @MariusRumpf, since you are the three top contributors to the project, I'm offering making you collaborators on Github so that you can author changes that affect Salvattore directly. Let me know if you're interested! cc @edadams |
👍 |
Hey @rnmp, thanks for the offering. I won't find the time to implement new features for this project, but some support should be no problem (for pull requests, questions, issues). |
Thanks for this @rnmp it's greatly appreciated. I can only second @MariusRumpf here, I am happy to help out with support whenever I can. |
Thanks guys, just added you as collaborators. Waiting to hear from @MoOx. |
Not interested sorry, I am already busy with a lot of other project like cssnext or stylelint. |
Feel free to use this PR in any way (PR on this PR, or manually rebase on master...) |
Understood @MoOx, thanks so much for contributing to the project and I'm deeply sorry again for lack of maintenance. Hopefully with the help of @MariusRumpf (who’s been doing a great job this weekend) and @attila will get up to speed. You guys are great. |
To anybody who is able to merge this: The HEAD of https://github.com/witrin/salvattore allows an auto merge. The reason why merging here is pain in the ass is because of the minified version |
@rnmp thanks for the info, and I think we all understand being busy ;) You've got a great idea here, I'm glad you chose to let the community help with this 👍 |
I think balanced columns should not overwrite the existing algorithm, which should still be default. We might add these setting in CSS: #grid[data-columns]::before {
content: '3 .column.size-1of3 balanced';
} We might use the ordered option (actual algorithm) by default if not provided then. This would fit our user group which might not be trained in javascript. Problem is that we cannot add endless settings here, since this will then get complex to check and to set the plugin up. Or we put it in JS: <script>
salvattore.init({
algorithm: 'balanced'
});
</script> This would mean we no longer init when the plugin is bound in and one has to call the init function to use it. This would break existing implementations, but would be easy to fix. It makes makes the basic integration a little harder and we drift a little more to the direction of the existing masonry plugin then. My vote would be for the css option. What do you think? @rnmp @attila @ppold |
It definitely should not be the default option. My biggest concern is that block heights are measurable only after load which limits use. Keep the config in CSS, let's not decide on the autoloading behaviour within this PR. Autoloading has been an outstanding issue for a while but I believe it should be worked out elsewhere. |
@MariusRumpf @attila I agree that it should not be the default and CSS option sounds great. Thanks so much for taking care of this. |
I integrated a basic version based on this pull request in the |
Thanks @MariusRumpf! /cc @MoOx |
@MoOx @rnmp @MariusRumpf is there a way to disable height balancing of any sort and only show columns with the contents in the order of original appearance? (like chronological order) |
@josephbergdoll the version from the new branch and the current released branch do not change the order, they keep it and do not balance when using existing settings. #grid[data-columns]::before {
content: '3 .column.size-1of3';
} To enable this feature in the branch that is not yet release you have to provide the balance keyword like so: #grid[data-columns]::before {
content: '3 .column.size-1of3 balanced';
} |
👍 just what I was looking for. |
Any progress on this? 😉 I was looking for this as well! |
Won't find the time to work on this in the near future. Feel free to give it a try, seems to work except when changing breakpoints on resize, the box order is different then. |
I have updated my fork with some tweaks on this PR. It is working much better than any other plugin. Let me know if you see any issues with it. |
Hi, this feature looks cool! Any progress? |
If only my skills were up to par… I'd do this myself… 😭 |
@stramel |
@MariusRumpf |
This commit include a new algorithm that handle elements height during
the repartition of the items.
The previous algorithm was pretty simple (just balance same amount of
items in each columns), and this can create visual issue if lots of
items have different heights.
I currently have an implementation that can use more than 5000 items, &
with this amount the differences are too big. Checkout an 
Here is a new algorithm that include a small process to retrieve
correct height (by appending them in a additional column
showing/retrieving value/removing ). Using a wrapper to append & remove
from the dom make this very fast. I don’t get any lag with lots of
items on my current board.
Should close #4 (& so close #52 )
A 2nd (simple) commit include fix for latest Chrome (Close #69 & close #40 )
It jshint ok (I've used default grunt) & it should be ok with your coding style. I hope so :)
It not really better on your example (in the repo) since the images doesn't have the appropriate height during loading, but in my case it give something really great (fyi I use https://github.com/suitcss/flex-embed/ to prepare my css to avoid issue like that, very nice for rwd).
This algorithm part should be easily skipped if wrapper in a conditional part (that can be enabled with an option).