var wpers = Math.max(0.1,allpers); var hpers = Math.max(0.1,allpers);
$(this).css({
"width":wpers*wid,
"height":hpers*hei,
"opacity":allpers
});
[b]2.3 索引值[/b]
视觉上距离我们最近的图片,应该是在最上层,即绝对定位的z-index应该是最大,反之而最小,因为这个值也是随图片运动而变化的,所以我们就用到上面的allpers比例值,这个值是0-1之间的,所以我们再用一个函数处理一下:
Math.ceil(allpers*10),让其值在1-10之间
(因为我们这里正好是十个图片,如果多了,这个公式需要变化一下)
[b]三、完整代码[/b]
$(function(){
//中心点横坐标
var dotLeft = ($(".container").width()-$(".dot").width())/2-100;
//中心点纵坐标
var dotTop = ($(".container").height()-$(".dot").height())/2-100;
//椭圆长边
a = 460;
//椭圆短边
b = 120;
//起始角度
var stard = 0;
//每一个BOX对应的角度;
var avd = 360/$(".container img").length;
//每一个BOX对应的弧度;
var ahd = avd*Math.PI/180;
//运动的速度
var speed = 2;
//图片的宽高
var wid = $(".container img").width();
var hei = $(".container img").height();
//总的TOP值
var totTop = dotTop+100;
//设置圆的中心点的位置
$(".dot").css({"left":dotLeft,"top":dotTop});
//运动函数
var fun_animat = function(){
speed = speed<360?speed:2;
//运运的速度
speed+=2;
//运动距离,即运动的弧度数;
var ainhd = speed*Math.PI/180;
//按速度来定位DIV元素
$(".container img").each(function(index, element){
var allpers = (Math.cos((ahd*index+ainhd))*b+dotTop)/totTop;
var wpers = Math.max(0.1,allpers);
var hpers = Math.max(0.1,allpers);
$(this).css({
"left":Math.sin((ahd*index+ainhd))*a+dotLeft,
"top":Math.cos((ahd*index+ainhd))*b+dotTop,
"z-index":Math.ceil(allpers*10),
"width":wpers*wid,
"height":hpers*hei,
"opacity":allpers
});
});
}
//定时调用运动函数
var setAnimate = setInterval(fun_animat,100);
})
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有