Hi dkimbell13:
That is a good idea,
I tried to do it like that, but it turns out to be a very long process, but I do not know a better way to get it done.
I first sorted by .offset().top 'rows' if you will. I did not manage that.
I confused myself a bit, here is my code maybe you see the logical error:
- var firstArr = $('div#content div.isotope-item img');//select visible images
- var idArr = new Array();
- var tempArr = new Array();
- var temp;
- for (var i = 0; i < firstArr.length; i++) {//loop through the image array
- temp = $(firstArr[i]);
- //add the image id, left offset and right offset into idArr
- idArr.push([temp.attr('id'), temp.offset().left, temp.offset().top]);
- //add the image top offset into tempArr
- tempArr.push(temp.offset().top);
- }
- //sort tempArr
- tempArr = quickSort(tempArr);
- //here I am trying to sort idArr based on the sorted tempArr
- //loop through each sorted element
- for (var i = 0; i <
tempArr.length; i++) {
- //loop through idArr
- for (var j = 0; j < idArr.length; j++) {
- //if idArr has the same top offset as tempArr, overwrite
tempArr with the complete value of idArr
- if (idArr[j][2] == tempArr[i]) {
- tempArr[i] = idArr[j];
- idArr[j] = [0,0,0];
- break;
- }
- }
- }
- //Here I get an array which is sorted, but only by row, Now i don't know how to sort by offset().left 'column'
Any ideas?
I bet there is an easier way, I just can't think of it now.
Thanks for helping!