在最后一张图片上停止jquery幻灯片放映
我正在使用Fotorama进行幻灯片放映,但在预设中没有选项来停止最后一张图像上的幻灯片 下面的脚本包含导航按钮,我正在发布它,因为它可能会有帮助…我一直在研究它,但我不熟悉jquery的编码…但我正在努力理解它 我注意到这个变量的大小是-5,它告诉脚本有多少张幻灯片。。。 还有var intervalInput=$(“#fotorama区间”);我认为可能需要告诉幻灯片它到达了最后一张图像 如果可以,请帮助我在最后一张图片上停止jquery幻灯片放映,jquery,slideshow,fotorama,Jquery,Slideshow,Fotorama,我正在使用Fotorama进行幻灯片放映,但在预设中没有选项来停止最后一张图像上的幻灯片 下面的脚本包含导航按钮,我正在发布它,因为它可能会有帮助…我一直在研究它,但我不熟悉jquery的编码…但我正在努力理解它 我注意到这个变量的大小是-5,它告诉脚本有多少张幻灯片。。。 还有var intervalInput=$(“#fotorama区间”);我认为可能需要告诉幻灯片它到达了最后一张图像 如果可以,请帮助我 <script> $(function () {
<script>
$(function () {
var $document = $(document);
var stage = $('#chromeless-stage');
var control = $('#fotorama-control');
var fotorama = $('#fotorama');
var activeIndex;
var arrows = $('#fotorama-arrows').find('input');
var thumbs = $('#fotorama-thumbs').find('a');
var size = 5;
// FOTORAMA
fotorama.fotorama({
data: [
{img: 'images/start-slide-1.jpg'},
{img: 'images/start-slide-2.jpg'},
{img: 'images/start-slide-3.jpg'},
{img: 'images/start-slide-4.jpg'},
{img: 'images/start-slide-5.jpg'}
],
width: '100%',
height: 'auto',
minHeight: 600,
fitToWindowHeight: true,
fitToWindowHeightMargin: 0,
margin: 0,
cropToFit: true,
shadows: false,
transitionDuration: 888,
loop: true,
autoplay: 2500,
stopAutoplayOnAction: false,
transition: 'fade',
nav: 'none',
arrows: false,
onClick: function(data)
{ window.location = 'about-ana-parzych-custom-cakes.html' },
/*transition: fade,*/
onShowImg: function(data, auto) {
if (!auto && playingFLAG) {
pause();
}
activeIndex = data.index;
thumbs.not(
thumbs.eq(activeIndex).addClass('active')
).removeClass('active');
if (activeIndex == 0) {
arrows.slice(0,2).attr({disabled: 'disabled'});
} else {
arrows.slice(0,2).removeAttr('disabled');
}
if (activeIndex == size - 1) {
arrows.slice(2).attr({disabled: 'disabled'});
} else {
arrows.slice(2).removeAttr('disabled');
}
}
});
// SLIDESHOW
var playButton = $('#fotorama-play');
var pauseButton = $('#fotorama-pause');
var intervalInput = $('#fotorama-interval');
var playingFLAG = false;
function changeThumbBorderColor() {
thumbs.parent()[(playingFLAG ? 'add' : 'remove') + 'Class']('autoplay');
}
function start() {
fotorama.trigger('play'); // Start playing
playingFLAG = false;
playButton.attr('disabled', 'disabled');
pauseButton.removeAttr('disabled');
changeThumbBorderColor();
}
function pause() {
fotorama.trigger('pause'); // Pause
playingFLAG = true;
pauseButton.attr('disabled', 'disabled');
playButton.removeAttr('disabled');
changeThumbBorderColor();
}
playButton.click(start);
pauseButton.click(pause);
// Custom interval
intervalInput.bind('click change keypress cut copy paste input', function(){
fotorama.data('options').autoplay = intervalInput.val()*1000;
if (playingFLAG) {
fotorama.trigger('pause');
fotorama.trigger('play');
}
});
// CUSTOM THUMBS AND ARROWS
arrows.bind('click', function(){
var index = $(this).attr('data-action');
if (index == 'next') {
index = activeIndex + 1;
} else if (index == 'prev') {
index = activeIndex - 1;
}
if (index > size - 1) {
index = size - 1;
}
if (index < 0) {
index = 0;
}
fotorama.trigger('showimg', index);
});
thumbs.bind('click', function(e){
fotorama.trigger('showimg', thumbs.index(this));
return false;
});
$document.bind('keydown', function(e){
if (!fotorama.hasClass('fotorama_fullscreen') && !intervalInput.is(':focus')) {
if (e.keyCode == 39 || e.keyCode == 40) {
fotorama.trigger('showimg', 'next');
return false;
} else if (e.keyCode == 37 || e.keyCode == 38) {
fotorama.trigger('showimg', 'prev');
return false;
}
}
});
// FULLSCREEN
$('#fotorama-fullscreen').bind('click', function(){
fotorama.trigger('fullscreenopen');
});
// RESCALE
/*var rescale = $('#fotorama-rescale').find('input');
rescale.bind('click', function(){
var $this = $(this);
rescale.not(
$this.attr({disabled: 'disabled'})
).removeAttr('disabled');
var newSize = $this.val().split(', ');
var width = newSize[0];
var height = newSize[1];
if (width == '100%') {
width = stage.width();
control.css({width: '50%'});
} else {
control.css({width: ''});
}
fotorama.trigger('rescale', [width, false, 700/467, 333]);
});*/
});
</script>
$(函数(){
var$document=$(文档);
var阶段=$(“#无铬阶段”);
变量控制=$(“#fotorama控制”);
变量fotorama=$(“#fotorama”);
var指数;
变量箭头=$('fotorama arrows')。查找('input');
var thumbs=$('fotorama thumbs')。查找('a');
变量大小=5;
//福托拉马
福托拉马,福托拉马({
数据:[
{img:'images/start-slide-1.jpg'},
{img:'images/start-slide-2.jpg'},
{img:'images/start-slide-3.jpg'},
{img:'images/start-slide-4.jpg'},
{img:'images/start-slide-5.jpg'}
],
宽度:“100%”,
高度:“自动”,
身高:600,
菲托维特:没错,
FittoWightMargin:0,
保证金:0,
克罗普托菲特:没错,
阴影:错,
过渡期:888,
循环:对,
自动播放:2500,
StopAutoPlayNaction:false,
过渡:“淡出”,
导航:“无”,
箭头:错,
onClick:函数(数据)
{window.location='about ana parzych custom cakes.html'},
/*过渡:褪色*/
onShowImg:功能(数据、自动){
如果(!auto&&playingFLAG){
暂停();
}
activeIndex=data.index;
拇指,不是(
thumbs.eq(activeIndex.addClass('active'))
).removeClass(“活动”);
如果(activeIndex==0){
arrows.slice(0,2).attr({disabled:'disabled'});
}否则{
箭头.slice(0,2).removeAttr('disabled');
}
如果(activeIndex==大小-1){
arrows.slice(2.attr)({disabled:'disabled'});
}否则{
arrows.slice(2.removeAttr('disabled');
}
}
});
//幻灯片放映
var playButton=$('fotorama play');
var pauseButton=$('fotorama pause');
var intervalInput=$(“#fotorama区间”);
var playingFLAG=false;
函数changeTumbBorderColor(){
thumbs.parent()[(播放标志?'add':'remove')+'Class']('autoplay');
}
函数start(){
fotorama.trigger('play');//开始播放
playingFLAG=false;
playButton.attr('disabled','disabled');
pauseButton.removeAttr('disabled');
changeThumbBorderColor();
}
函数暂停(){
fotorama.trigger('pause');//pause
playingFLAG=true;
attr('disabled','disabled');
playButton.removeAttr(“禁用”);
changeThumbBorderColor();
}
播放按钮。单击(开始);
暂停按钮。单击(暂停);
//自定义间隔
intervalInput.bind('单击更改按键剪切复制粘贴输入',函数()){
fotorama.data('options').autoplay=intervalInput.val()*1000;
如果(播放旗帜){
fotorama.trigger(‘暂停’);
fotorama.trigger(“play”);
}
});
//自定义拇指和箭头
arrows.bind('click',function(){
var index=$(this.attr('data-action');
如果(索引==“下一步”){
index=activeIndex+1;
}否则如果(索引=='prev'){
index=activeIndex-1;
}
如果(索引>大小-1){
指数=大小-1;
}
如果(指数<0){
指数=0;
}
触发器('showimg',索引);
});
thumbs.bind('click',函数(e){
fotorama.trigger('showimg',thumbs.index(this));
返回false;
});
$document.bind('keydown',函数(e){
如果(!fotorama.hasClass('fotorama_fullscreen')&&!intervalInput.is(':focus')){
如果(e.keyCode==39 | | e.keyCode==40){
触发器('showimg','next');
返回false;
}else if(e.keyCode==37 | | e.keyCode==38){
触发器('showimg','prev');
返回false;
}
}
});
//全屏
$('fotorama fullscreen').bind('click',function(){
fotorama.trigger(“全屏打开”);
});
//重新缩放
/*var rescale=$('fotorama rescale')。查找('input');
重缩放.bind('单击',函数()){
var$this=$(this);
重新缩放(
$this.attr({disabled:'disabled'})
).removeAttr(“禁用”);
var newSize=$this.val().split(',');
变量宽度=新闻大小[0];
变量高度=新闻大小[1];
如果(宽度='100%'){
宽度=stage.width();
css({width:'50%});
}否则{
css({宽度:'});
}
fotorama.trigger('rescale',[width,false,700/467333]);
});*/
});
如果您使用Fotorama 3:
var fotorama = $('#fotorama');
fotorama.fotorama({
onShowImg: function () {
var data = fotorama.data();
if (data.size - data.index === 1) {
fotorama.trigger('pause');
}
}
});
小提琴:
$('.fotorama').on('fotorama:showend', function (e, fotorama) {
if (fotorama.size - fotorama.activeIndex === 1) {
fotorama.stopAutoplay();
}
});