Skip to content

Instantly share code, notes, and snippets.

@diaspar
Created December 19, 2019 15:15
Show Gist options
  • Save diaspar/f42d174f7bb3f9bc2a798e22a713ee3a to your computer and use it in GitHub Desktop.
Save diaspar/f42d174f7bb3f9bc2a798e22a713ee3a to your computer and use it in GitHub Desktop.
// Homepage Fake Candidates Profiles
Drupal.behaviors.FakeCandidatesProfiles = {
attach: function (context, settings) {
var max = 3;
var offset = 3;
var developers = $('.view-display-id-developers_header .views-row').clone();
var SLIDER_TIME = 4000;
var ANIMATION_TIME = 1000;
$('.view-display-id-developers_header .views-row').remove();
for (var i=0; i < max; i++ ) {
$(developers[i]).addClass('active');
$('.view-display-id-developers_header .view-content').append(developers[i]);
}
var developersSliderAnimate = function() {
var sliderDevelopers = $('.view-display-id-developers_header .views-row');
var newItem = $(developers[offset]).clone();
var positionOne = $(sliderDevelopers[0]).position();
var positionTwo = $(sliderDevelopers[1]).position();
$('.view-display-id-developers_header .view-content').append(newItem);
$(sliderDevelopers[0]).fadeOut(ANIMATION_TIME, function() {
newItem.fadeIn();
});
$(sliderDevelopers[1]).animate(positionOne, ANIMATION_TIME, function() {
$(sliderDevelopers[0]).remove();
$(sliderDevelopers[1]).removeAttr('style');
});
$(sliderDevelopers[2]).animate(positionTwo, ANIMATION_TIME, function() {
$(sliderDevelopers[2]).removeAttr('style');
newItem.fadeIn();
newItem.addClass('active');
});
offset++;
if (offset >= developers.length) {
offset = 0;
}
};
setInterval(developersSliderAnimate, SLIDER_TIME);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment