Following on from a solution posted here: Velocity.js/Blast.js starting opacity at 0
I am using Velocity.js and Blast.js to create a simple load in each word as an animation... one of the basic setups. I am also using this alongside Cycle2. I am also using fullpage.js, so sometimes a text slide might be the first slide, so is it possible to do the same thing on sliding down?
- If the text slide, with the animation, is also the first slide, to trigger the animation from opacity:0 just as it does if you navigate prev/next.
I have set up a JSFiddle, adding the fullpage.js, so if you scroll down I've made the second section start with text but it doesn't animate or show. I've also added in onLeave and afterLoad callbacks for you to use if that helps? jsfiddle.net/h3vo8LL1/4/
//
if ($('.home-section-container').length > 0) {
$('.home-section-container').fullpage({
sectionSelector: '.each-section',
scrollingSpeed: 1000,
resize: false,
onLeave: function () {
//
},
afterLoad: function () {
//
}
});
}
//
function featuredProjectTextAnimation(incomingSlideEl) {
var $animated = $(incomingSlideEl).find('.text-container.animated');
$animated.blast({
delimiter: 'word'
})
.velocity('transition.fadeIn', {
display: null,
duration: 0,
stagger: 100,
delay: 400,
begin: function () {
$animated.css('opacity', 1);
},
complete: function () {
//
}
});
}
//
if ($('.home-slider-container').length > 0) {
$('.home-slider-container .home-slider').each(function () {
var $this = $(this);
var slideCount = $this.find('.each-slide').length;
if (slideCount <= 1) {
$this.next('.home-slider-pager').remove();
$this.prev('.home-slider-navigation').remove();
}
$this.cycle({
fx: 'fade',
slides: '> .each-slide',
caption: $this.next('.home-slider-pager'),
captionTemplate: '{{slideNum}}/{{slideCount}}',
sync: true,
timeout: 0,
random: false,
pagerActiveClass: 'active',
next: $this.prev('.home-slider-navigation').find('.next'),
prev: $this.prev('.home-slider-navigation').find('.prev'),
loader: true,
autoHeight: 'container',
swipe: true
});
$this.on('cycle-before', function () {
});
$this.on('cycle-after', function (event, optionHash, outgoingSlideEl, incomingSlideEl) {
featuredProjectTextAnimation(incomingSlideEl);
$(outgoingSlideEl).find('.text-container.animated').css('opacity', 0);
});
});
}