Skip to content

Instantly share code, notes, and snippets.

@gusmantap
Created January 24, 2018 02:55
Show Gist options
  • Save gusmantap/736544a5b1cd73fc06bd5ef2df151dd6 to your computer and use it in GitHub Desktop.
Save gusmantap/736544a5b1cd73fc06bd5ef2df151dd6 to your computer and use it in GitHub Desktop.
var MarketingCommunication = function(elem){
i = 0;
setInterval(function(){
var current = i;
var before = (current - 1) == -1 ? (elem.length - 1) : (current - 1);
var after = current + 1;
elemBefore = elem.eq(before);
elemCurrent = elem.eq(current);
elemAfter = elem.eq(after);
elemBefore.removeClass("in").addClass("out");
elemCurrent.removeClass("out");
if(current == 0){
setTimeout(function(){
elemCurrent.addClass("in");
}, 1500);
} else if(current == 1) {
setTimeout(function(){
elemCurrent.addClass("in");
}, 2000);
}
setTimeout(function(){
if(elem.eq(current).hasClass('marketing')){
$("#simple-d-utilisation span.communication").removeClass("bold");
$("#simple-d-utilisation span.marketing").addClass("bold");
} else {
$("#simple-d-utilisation span.marketing").removeClass("bold");
$("#simple-d-utilisation span.communication").addClass("bold");
}
}, 1500);
i++;
if(i < elem.length){
} else {
i = 0;
}
}, 12000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment