Created
December 19, 2019 15:15
-
-
Save diaspar/f42d174f7bb3f9bc2a798e22a713ee3a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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