Skip to content

[Carousel] Need advice to add a counter #83

Answered by fancyapps
bckthomas asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,

See this demo - https://fancyapps.com/playground/FS

const myCarousel = new Carousel(document.querySelector("#myCarousel"), {
  Dots: false,
  on: {
    init: (carousel) => {
      carousel.$index = carousel.$container.querySelector(".carousel_index");
      carousel.$count = carousel.$container.querySelector(".carousel_count");
    },
    refresh: (carousel) => {
      if (carousel.$count) {
        carousel.$count.innerHTML = carousel.pages.length;
      }
    },
    change: (carousel) => {
      if (carousel.$index) {
        carousel.$index.innerHTML = carousel.page + 1;
      }
    },
  },
});

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@bckthomas
Comment options

Answer selected by bckthomas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants