在fullpage.js上获取当前幻灯片
Get current slide on fullpage.js
我是一个快乐的Fullpage.js用户!
我只是想添加一个类(.num)来显示当前幻灯片的数量/幻灯片的总数。
我使用的这个函数工作得很好,问题是它在幻灯片更改时不更新。
$('.section').each(function(){
var section = $(this),
sectionSlides = section.find('.slide'),
totalItems = sectionSlides.length,
currentIndex = sectionSlides.filter('.active').index() + 2,
numContainer = section.find('.num');
numContainer.html(currentIndex + ' / ' + totalItems);
});
http://jsfiddle.net/168xofn3/11/三种方式
- 使用回调,如
onSlideLeave
. - 使用fullPage.js添加的状态类之一
- 就像
$('.fp-section.active').find('.fp-slide.active');
我相信这段代码可以解决我的问题,我只需要改变警报也许?
$('#fullpage').fullpage({
onSlideLeave: function( anchorLink, index, slideIndex, direction, nextSlideIndex){
var leavingSlide = $(this);
//leaving the first slide of the 2nd Section to the right
if(index == 2 && slideIndex == 0 && direction == 'right'){
alert("Leaving the fist slide!!");
}
//leaving the 3rd slide of the 2nd Section to the left
if(index == 2 && slideIndex == 2 && direction == 'left'){
alert("Going to slide 2! ");
}
}
});
相关文章:
- 使用 jQuery 的 .on 函数如何获取事件的原始元素
- 幻灯片滚动javascript不起作用
- jquery试图按名称获取按钮位置
- 如何在jQuery中获取元素的形式
- 让文本输入幻灯片显示输入时的新文本输入?然后向后滑动
- 如何在Slick Carousel中获取活动中的幻灯片元素
- 获取完整页面上加载的幻灯片.js slideload回调
- 需要获取当前幻灯片编号 - 基本 JQuery 滑块
- 如何在滑翔.js中获取当前幻灯片
- 在 JQuery 循环中,如何获取当前幻灯片的 src
- 光滑的旋转木马如何将当前幻灯片作为 dom 或 jquery 对象获取
- 如何获取 HTML5 范围(2 张幻灯片)滑块在 PHP 中的值
- 如何获取最后一张和第一张幻灯片以相应地激活或禁用下一个和上一个按钮
- 如何在bxslider中获取一组活动幻灯片
- 获取活动幻灯片并更新每张新幻灯片上的数字
- 在fullpage.js上获取当前幻灯片
- Javascript幻灯片问题.正在获取空白屏幕
- 使用书排.js时获取当前幻灯片编号
- 如何在弹性滑块中获取幻灯片总数
- jQuery自制幻灯片代码似乎无法获取图像的当前上下文