Skip to content

A question about showing more items in a carousel? #30

@zhouhao27

Description

@zhouhao27

This is the best jquery carousel I've ever seen online. I'm going to extend your example 2 to show more items.

Code in index.html:

<script>
$(function() {
  $.responsiveHub({
    layouts: {
      480:  "phone",
      481:  "small-tablet",
      731:  "tablet",
      1199: "small-web",
      1200:  "web"
    },
    defaultLayout: "web"
  });
});
</script>

In css:

.view-port, .track .inner {
   /*original value: width: 946px;*/
   width: 1180px;
}

In example2_and_3.js:

   onChange: function(track, options, event) {
    track.options.mode = "horizontal";
    track.options.autoHeight = false;
    track.options.perPage = 5;

    if (event.layout === "small-web") {
      alert('small-web');
      track.options.perPage = 4;
      if (track.container.hasClass("huge")) {
        track.options.autoHeight = true;
      }          
    } else if (event.layout === "small-tablet") {
      track.options.perPage = 3;
      if (track.container.hasClass("huge")) {
        track.options.autoHeight = true;
      }
    } else if (event.layout === "phone") {
      track.options.perPage = 3;
      track.options.mode = "vertical";
      track.options.autoHeight = true;
    }

    track.restart({keepCurrentPage: true});
  }

Here is the result when browser width is greater than 1200. It looks great:

2015-10-14 12 52 41

But when I resize the browser width to less than 1200, it shows part of the items which is not what I expected:

2015-10-14 12 52 57

Can you advise what I did wrong? Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions