继此处发布的解决方案之后:Velocity.js/Blast.js 从 0 开始不透明度
我正在使用 Velocity.js 和 Blast.js 在每个单词中创建一个简单的加载作为动画......基本设置之一。我也在 Cycle2 旁边使用它。我也在使用 fullpage.js,所以有时文本幻灯片可能是第一张幻灯片,那么向下滑动时是否可以做同样的事情?
- 如果带有动画的文本幻灯片也是第一张幻灯片,则从 opacity:0 触发动画,就像导航上一个/下一个一样。
我已经设置了一个 JSFiddle,添加了 fullpage.js,所以如果你向下滚动,我已经让第二部分以文本开头,但它没有动画或显示。如果有帮助,我还添加了 onLeave 和 afterLoad 回调供您使用?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);
});
});
}