Hi
I have a dynamic carousel. in which item varies from 2 to 14.
Now if i have 2 items, then i want to show as soon as i load the carousel the right arrow disabled. How wud i show it on loading the carousel itself.
Below is the code to handle the carousel arrows.
- function filterArrowButtonWasClicked(event) {
- var content = $('carousel_content');
- var offset = parseInt(content.readAttribute('data-offset'), 10);
- var no_of_products = parseInt(ACProductBrowser.products.products.length, 10);
- var remainingProducts = Math.floor(no_of_products % 6);
- var totalWidth = 138.5 * remainingProducts;
- var slideTo = totalWidth + 830;
- var initialWidth = 830;
- if (no_of_products <= 6 || no_of_products < 12 ) {
- initialWidth = totalWidth;
- slideTo = totalWidth;
- } else {
- initialWidth = 830;
- }
- if (event.target.id == 'right_arrow') {
- $('left_arrow').removeClassName('disabled');
- offset = Math.max(offset - initialWidth, -slideTo);
- if (offset == -slideTo) {
- $('right_arrow').addClassName('disabled');
- }
- } else {
- $('right_arrow').removeClassName('disabled');
- offset = Math.min(offset + initialWidth, 0);
- if (offset == 0) {
- $('left_arrow').addClassName('disabled');
- }
- }
- content.writeAttribute('data-offset', offset);
- content.style.webkitTransform = 'translateX(' + offset + 'px)';
- content.style.MozTransform = 'translateX(' + offset + 'px)';
- content.style.OTransform = 'translateX(' + offset + 'px)';
- content.style.msTransform = 'translateX(' + offset + 'px)';
- content.style.left = offset + 'px';
- }
But this function will be called only when i click any arrow. in case of two items, the arrows shud be disabled right away. how to do this?