Skip to content

Instantly share code, notes, and snippets.

@hogash
Forked from bbrochier/caroufredsel-base.js
Created July 14, 2016 15:23
Show Gist options
  • Save hogash/3f804718586686d6cd6f5fdd1c5d5c9c to your computer and use it in GitHub Desktop.
Save hogash/3f804718586686d6cd6f5fdd1c5d5c9c to your computer and use it in GitHub Desktop.
CarouFredSel Doc
// Carousel slider
if ($("#slider").length){
$(".slider").carouFredSel({
prev: '.btn-prev',
next: '.btn-next',
pagination: ".pagination",
items: {
visible: 3,
width: 300
},
width: 900,
height: 150,
align: 'left', //needed when only 1 or 2 items displayed (+ margin right on item)
scroll: {
duration: 1000,
pauseOnHover: true,
easing: "quadratic"
},
swipe: {
onMouse: true,
onTouch: true,
options: {
//liste d'exclusion par defaut moins l'element <a>
excludedElements: "button, input, select, textarea, .noSwipe",
//recherche et trigger du <a> au tap
tap: function(event, target) {
window.open($(target).closest('a').attr('href'), '_self');
}
}
}
});
};

###Documentation

0. Old Doc

http://docs.dev7studios.com/caroufredsel-old/code-examples/configuration.php

1. Carousel in a display:none parent

#####Problem: When the carousel is in a displayed none parent, it gets a height=0 at the init.

#####Solution

  • Set the parent to display none as a display block in the css.
  • Set the wrapper of the slider as fixed :
.sliderWrapper {
    position: fixed;
    left: -9990px;
}

In caroufredsel options add the onCreate option which fires when the carousel is initiated. It will set the wrapper back to a static position and hide the parent which is supposed to be hidden.

onCreate: function(){
  $('.sliderWrapper').css({'position':'static', 'left':0});
  $('#divParentToDisplayNone').css({'display':'none'});
}

2. Refresh carousel size

$('#myCaroufredsel').trigger('updateSizes');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment