Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 260
  • Last Modified:

Galleriffic Jquery

I am using a Galleriffic query gallery to display images . The problem is that I need to order the display of the images, so that they load vertically first then horizontally - the total size is 2 down x10 across. By default it loads horizontally first. Does anyone know how to do this. Many Thanks.
0
fred2k3
Asked:
fred2k3
  • 3
2 Solutions
 
Julian HansenCommented:
I expect you will need to change the order of your images. The plugin is laying out the images in standard HTML layout which is left to right before wrapping to the next line.

If you want it to go vertiaclly you will probably have to order your images so that each Nth image is the next successive one where N is the number of images that will fit horizontally in your container. So if 3 images can fit horizontally

Image 1
Image 4
Image 7
Image 2
Image 5
Image 8
Image 3
Image 6
Image 9
Image 10
0
 
Julian HansenCommented:
If your images are loaded dynamically then you can probably re-order them with a JQuery piece of code like this
// NUMBER OF IMAGES TO SHOW HORRIZONTALLY
var containersize = 3;
$(function() {

  // DETACH IMAGES INTO ARRAY OF ELEMENTS      
  var imgs = $('#gallerific img').detach();

  // DECLARE ARRAY FOR OUR SORTED IMAGES
  var n = Array();

  // INDEX FOR NEW ARRAY
  var c = 0;

  // LOOP THROUGH COLUMNS
  for(i = 0; i< containersize;i++) {
    
    // FOREACH COLUMN ADD THE nTH ITEM TO THE NEW ARRAY
    for(j = i; j < imgs.length; j+= containersize) {
      n[c++] = imgs[j];
    }
  }

  // APPEND IMAGES BACK TO CONTAINER
  $('#gallerific').append(n);

  // INITIALISE GALLERIFIC HERE
});

Open in new window

0
 
fred2k3Author Commented:
Thanks, very much appreciated.
0
 
Julian HansenCommented:
You are welcome - thanks for the points.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now