图片照片库
Image photo gallery
本文关键字:照片库 更新时间:2023-09-26
我创建了一个图片照片库。
当我单击下一个和上一个按钮时,我上下设置了它的样式
当我单击上一个和下一个时,我需要它并排出现。
这是演示
http://jsfiddle.net/T657N/16/
刚刚将 top
参数更改为脚本内部的left
。
在这里演示
您只需更改 javascript 的 SwapFirstLast(( 函数:
取代
$(this).animate({ 'top' : direction + $(this).height() + 'px' }, 'slow', function() { //animate the img above/under the gallery (assuming all pictures are equal height)
$(this).css('z-index', newZindex) //set new z-index
.animate({ 'top' : '0' }, 'slow', function() { //animate the image back to its original position
inAnimation = false; //reset the flag
});
});
跟
$(this).animate({ 'left' : direction + $(this).height() + 'px' }, 'slow', function() { //animate the img above/under the gallery (assuming all pictures are equal height)
$(this).css('z-index', newZindex) //set new z-index
.animate({ 'left' : '0' }, 'slow', function() { //animate the image back to its original position
inAnimation = false; //reset the flag
});
});
所以最后你的函数将是:
function swapFirstLast(isFirst) {
if(inAnimation) return false; //if already swapping pictures just return
else inAnimation = true; //set the flag that we process a image
var processZindex, direction, newZindex, inDeCrease; //change for previous or next image
if(isFirst) { processZindex = z; direction = '-'; newZindex = 1; inDeCrease = 1; } //set variables for "next" action
else { processZindex = 1; direction = ''; newZindex = z; inDeCrease = -1; } //set variables for "previous" action
$('#pictures img').each(function() { //process each image
if($(this).css('z-index') == processZindex) { //if its the image we need to process
$(this).animate({ 'left' : direction + $(this).height() + 'px' }, 'slow', function() { //animate the img above/under the gallery (assuming all pictures are equal height)
$(this).css('z-index', newZindex) //set new z-index
.animate({ 'left' : '0' }, 'slow', function() { //animate the image back to its original position
inAnimation = false; //reset the flag
});
});
} else { //not the image we need to process, only in/de-crease z-index
$(this).animate({ 'top' : '0' }, 'slow', function() { //make sure to wait swapping the z-index when image is above/under the gallery
$(this).css('z-index', parseInt($(this).css('z-index')) + inDeCrease); //in/de-crease the z-index by one
});
}
});
return false; //don't follow the clicked link
}
希望对您有所帮助。
相关文章:
- 图片照片库
- 强制从手机上的照片库上传照片文件
- JS照片库.使大图像显示和缩略图可单击
- 移动照片库应用程序
- 如何在照片库中添加分页
- 在照片库中的两个元素之间切换样式会发生变化
- 如何实现复选框或面向类别的照片库
- 单击照片库中的图像
- 照片库css所选状态未被cookie读取
- 使用 PHP 或 Javascript 生成自动照片库
- 如何为图像创建具有随机大小的磁贴照片库
- 如何将不区分大小写添加到照片库搜索框jquery
- iPhone上的html文件到照片库的屏幕截图
- 带阴影盒的照片库的列表/网格切换
- 现有 JavaScript 照片库的图像淡入淡出效果
- 如何在Android上使用PhoneGap从照片库中获取图片
- 在执行漂亮的照片库后从“导航”中删除类“粘性”的错误
- Javascript:带有前进/后退按钮的照片库
- 使用Phonegap将图像保存到Iphone照片库
- 搜索 3D 照片库(HTML5 或 Flash)