基于jQuery实现猎豹浏览器页面滑动效果



28 109 37



特效描述:基于jQuery实现 猎豹浏览器 页面滑动,基于jQuery实现猎豹浏览器页面滑动效果

代码结构

1. 引入CSS

<link href="css/style.css" rel="stylesheet" />

2. 引入JS

<script language="javascript" type="text/javascript" src="js/jquery.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.easing.js"></script>

3. HTML代码

<div id="pic1" num="1">
	<div class="nag">
		<div  class="ac active"><b></b></div>
		<div class="ac"><b></b></div>
		<div class="ac"><b></b></div>
		<div class="ac"><b></b></div>
		<div class="icon">
			<div class="xinlan"></div>
			<div class="tenxun"></div>
		</div>
	</div>
	<div class="divtop">
		<img id="btntop" class="btntop" src="images/top.png" />
	</div>
	<div class="back a1">
		<a class="a1_one"></a>
		<a id="a1_a" class="a_0" target="_blank" href="http://51qianduan.com/"></a>
		<!--<div class="a1_img">
			<img src="images/1.gif" />
			<img src="images/2.gif" />
			<img src="images/3.gif" />
		</div>
		<p id="n1p">欢迎使用猎豹浏览器4.0</p>
		<img id="n11img" class="n11" src="images/toptext.png" />
		<img id="n12img" class="n12" src="images/lbt.png" />-->
	</div>
	<!--<div class="back a2">
		<div class="n2"></div>
		<div id="n2yue1" class="n2yue1"></div>
		<div id="n2yue2" class="n2yue2"></div>
		<div id="hjimg" class="hjimg"></div>
	</div>-->
	<div class="back a2">
		<div class="n3">
			<a target="_blank" href="http://51qianduan.com/"></a>
		</div>
		<div id="n1yue3" class="yue3"></div>
		<img src="images/$.png"  class="yu1" />
		<img src="images/$.png"  class="yu2 yutop" />
		<img src="images/$.png"  class="yu3 yutop" />
		<img src="images/$.png"  class="yu4 yutop" />
	</div>
	<div class="back a3">
		<div class="n4"></div>
		<div id="n4yue1" class="n4yue1"></div>
		<div id="n4yue2" class="n4yue2"></div>
		<div class="zhuoz"></div>
		<img id="n5img" class="n5img" src="images/n5.png" />
	</div>
	<div class="back a4">
		<div class="n5">
			<a target="_blank" href="http://51qianduan.com/"></a>
		</div>
	</div>
</div>
<script>
	//var index_img=0;
	/*$(".a1_img img").eq(0).fadeIn("slow");
	setInterval(function(){
		var index_0=index_img;
		index_img=index_img+1;
		if(index_img>=3) index_img=0;
		$(".a1_img img").eq(index_0).fadeOut("slow");
		$(".a1_img img").eq(index_img).fadeIn("slow");
		$("#a1_a").attr("class","a_"+index_img)
	},5000);*/
	function $en(tit){return encodeURIComponent(tit)}
	var title="我的天啊,大家快来用下新版猎豹浏览器4.0~真的太快了!跟光速似的!其他浏览器都弱爆了!!!网购上当还赔你钱,48360元哦~~不用猎豹用啥??不信?那就试试看!下载地址>>http://51qianduan.com/忽悠你的话,俺请你吃饭!";
	//var url="http://51qianduan.com/";
	var pic="http://www.liebao.cn/images/iconpic.png";
	$(".xinlan").click(function(){
		window.open('http://v.t.sina.com.cn/share/share.php?appkey=962772401&title='+$en(title)+'&pic='+pic);
	})
	$(".tenxun").click(function(){
		window.open('http://v.t.qq.com/share/share.php?title='+$en(title)+'&pic='+pic);
	})
	var h=$(window).height();
	var w=$(window).width();
	//var h1=(h1-500<30?30:h-580)+"px";
	//$(".divtop").css("bottom",h1);
	$(".back").css("height",h+"px");
	$(".nag").css("top",$(window).scrollTop() + 250 +"px");
	$(".yutop").css("top",(h+150)+"px");
	$("#hjimg").css("top",(h+430)+"px");
	var yueAnimate={
		lbyFun:function(){
			$("#n11img").css({"width": "65px","height": "5px","top": "300px","margin-left": "-32px","opacity":"0"});
			$("#n12img").css({"opacity":"0"});
			$("#n1p").css({"opacity":"0"});
			var y=460;
			$("#n12img").animate({
				"opacity": 1
			},800,'easeInCubic');
			$("#n1p").animate({
				"opacity": 1
			},800,'easeInCubic',function(){
				$("#n11img").animate({
					"opacity": 0.8,
					"width":"328px",
					"height":"27px",
					"top": "275px",
					"margin-left":"-164px"
				},400,'easeInCubic',function(){
					$("#n11img").animate({
						"opacity": 1,
						"width":"273px",
						"height":"22px",
						"top": "285px",
						"margin-left":"-137px"
					},200,"easeInCubic")
				});
			});
		},
		btntop :function(){
			$("#btntop").css({"margin-top": "0px"});
			$("#btntop").animate({
				"margin-top": "30px"
			},1000,'easeOutBounce');
		},
		yue :function(id,left,right,time){
			$(id).animate({
				"margin-left": right
			},time,function(){
				$(id).animate({
					"margin-left": left
				},time);
			});
		},
		hjFun:function(){
			$("#hjimg").css("top",($(window).height()+430)+"px");
			$("#hjimg").css("margin-left","-824px");
			$("#n2yue1").css("margin-left","-560px");
			$("#n2yue2").css("margin-left","55px");
			$("#hjimg").animate({
				"top": "230px",
				"margin-left":"-340px"
			},1000,'easeInOutQuint');
		},
		yuFun:function(){
			var x=$(window).width()/2-500+210;
			x=x<210?210:x;
			var y=460;
			$(".yutop").css("top",(h+150)+"px");
			$(".yu1").css({"left": "50px","top": "260px"});
			$(".yu2").css({"left": "250px"});
			$(".yu3").css({"left": "450px"});
			$(".yu4").css({"left": "650px"});
			$(".yu1").animate({
				"left": x-170+"px",
				"top":"384px"
			},1000,'easeInCubic');
			$(".yu2").animate({
				"left": x-160+"px",
				"top":"479px"
			},1000,'easeInCubic');
			$(".yu3").animate({
				"left": x-55+"px",
				"top":"509px"
			},1000,'easeInCubic');
			$(".yu4").animate({
				"left": x+38+"px",
				"top":"468px"
			},1000,'easeInCubic');
		},
		n5imgFun:function(){
			$("#n5img").css({"width": "20px","height": "16px","top": "470px","margin-left": "75px","opacity":"0"});
			var y=460;
			$("#n5img").animate({
				"opacity": 0.5,
				"width":"350px",
				"height":"276px",
				"top": "250px",
				"margin-left":"-70px"
			},800,'easeInBack',function(){
				$("#n5img").animate({
					"opacity": 1,
					"width":"320px",
					"height":"252px",
					"top": "260px",
					"margin-left":"-60px"
				},300,"easeInBack")
			});
		}
	}
	//鼠标滚动事件 
	var shubiao=true;
	var wheel = function(event) {  
		var delta = 0;  
		if (!event)
			event = window.event;  
		if (event.wheelDelta) {
			delta = event.wheelDelta / 120;
		} else if (event.detail) {
			delta = -event.detail / 3;
		}
		if (delta) handle(delta);
		if (event.preventDefault) event.preventDefault();  
		event.returnValue = false;  
	}
	if (window.addEventListener) window.addEventListener('DOMMouseScroll', wheel, false);
	document.onmousewheel = wheel;
	var $f=true;
	var handle = function(delta) {
		if(!shubiao) return;
		shubiao=false;
		var random_num = Math.floor((Math.random() * 100) + 50);
		if (delta < 0) {
			PicWheelScroll(1);
			$f=false;
			 //console.log("鼠标滑轮向下滚动:" + delta + "次!"); // 1  
			return false;  
		} else {
			$f=true;
			PicWheelScroll(0);
			//console.log("鼠标滑轮向上滚动:" + delta + "次!"); // -1  
			return false;  
		}
	}
	$(".ac").each(function(i){
		$(this).click(function(){
			$(".ac").removeClass("active");
			$(".ac").eq(i).addClass("active");
			var num=i+1;
			if(num=="4") $("#btntop").hide();
			else $("#btntop").show();
			gotoAnchor($(".a"+num));
			getAnchroFun(num);
		})
	})
	var PicWheelScroll = function(n){
		var num=$("#pic1").attr("num");
		if((num===4&&n===1) || (num===1&&n===0)) return;
		if(n==1){
			if(num<4) num++;
		}else{
			if(num>1) num--;
		}
		$(".ac").removeClass("active");
		$(".ac").eq(num-1).addClass("active");
		if(num=="4") $("#btntop").hide();
		else $("#btntop").show();
		gotoAnchor($(".a"+num));
		getAnchroFun(num);
	}
	yueAnimate.yue("#n1yue3","-510px","-150px",10000);
	yueAnimate.yue("#n2yue1","-560px","-375px",10000);
	yueAnimate.yue("#n2yue2","55px","260px",10000);
	yueAnimate.yue("#n4yue1","-240px","-160px",10000);
	yueAnimate.yue("#n4yue2","120px","230px",10000);
	setInterval(function(){
		yueAnimate.yue("#n1yue3","-510px","-300px",10000);
		yueAnimate.yue("#n2yue1","-560px","-375px",10000);
		yueAnimate.yue("#n2yue2","55px","260px",10000);
		yueAnimate.yue("#n4yue1","-240px","-160px",10000);
		yueAnimate.yue("#n4yue2","120px","230px",10000);
	},22000);
	setInterval(yueAnimate.btntop,2000);
	var getAnchroFun=function(num){
		var h=$(window).height();
		var h=(h-500<30?30:h-580)+"px";
		$(".divtop").css("bottom","30px");
		var n=$("#pic1").attr("num");
		switch(parseInt(num)){
			case 1:
				if(n==1&&$f) return false;
				yueAnimate.lbyFun();
				break;
			case 2:
				yueAnimate.yuFun();
				break;
			case 3:
				yueAnimate.n5imgFun();
				break;
			case 4:
				break;
		}
		$("#pic1").attr("num",num);
	}
	var gotoAnchor = function(selector,isauto){
		var anchor = $(selector);
		if (anchor.length < 0) return;
		var $win=$(window);
		var $body = $(window.document.documentElement);
		var ua = navigator.userAgent.toLowerCase();
		if (ua.indexOf("webkit") > -1) {
			$body = $(window.document.body)
		}
		var pos=anchor.offset();
		if (isauto) {
			var t = pos.top - $win.scrollTop(); //相对于屏幕显示区
			var t2 = $win.height() - t;
			if (t2 < anchor.outerHeight()) {
				$body.animate({"scrollTop": pos.top}, "normal");
			}
			return;
		}
		$body.animate({"scrollTop": pos.top},{queue :false,complete: function(){shubiao=true;}});
	}
	gotoAnchor($(".a1"));
	yueAnimate.lbyFun();
	$(window).resize(function(){
		var h=$(window).height();
		$(".back").css("height",h+"px");
		var n=$("#pic1").attr("num");
		var h1=(h-500<30?30:h-580)+"px";
		//if(n==1) $(".divtop").css("bottom",h1);
		//else 
		$(".divtop").css("bottom","30px");
		gotoAnchor($(".a"+n));
	});
	$(".divtop").click(function(){
		var n=$("#pic1").attr("num");
		if(n=="3") $("#btntop").hide();
		n=parseInt(n)+1;
		if(n==5) {return;}
		$(".ac").removeClass("active");
		$(".ac").eq(n-1).addClass("active");
		gotoAnchor($(".a"+n));
		getAnchroFun(n);
		$("#pic1").attr("num",n);
	})
</script>
<div style="text-align:center;clear:both">
</div>



用户评论
大牛,别默默的看了,快登录帮我点评一下吧!:)      登录 | 注册


热门标签: 图片叠加 图片层叠 图片翻转 图片旋转 图片延迟加载 图片延迟 图片加载 图片拖动 图片拖拽 图片淡出淡进 图片淡出 图片淡进 图片全屏 头像上传 图片上传 二维码 图片放大镜 h5图片动画 h5图标动画 html5图片动画 html5图标动画 带缩略图的幻灯片 地图 中国地图 世界地图 滑动 滑块 滑动门 触屏滑动 滑动插件 滑块插件 图片放大缩小 图片缩放 图片大小 图片放大 图片缩小 图片变大 图片变小 滚动切换 滚动条切换 滑动选项卡 滑动切换 图片广告 图片收缩展开 图片收缩 图片展开 纯图片轮播 图片轮播 图片滚动 图片滚动条 图片滑动 图片滑块 旋转木马 图片旋转木马 文字旋转木马 旋转木马插件 图片切换 图片选项卡 图标选项卡 自动滚动图片轮播 图标导航 图标菜单 选项卡切换 选项卡 切换 tab切换 页面切换 选项卡插件 切换插件 滑动手风琴 背景切换 大图切换 手风琴 水平手风琴 垂直手风琴 图片手风琴 文字手风琴 手风琴插件 图表 图片 图片插件 头像截图 滑动选项卡 滑动切换 全屏切换 图片切换 切换图片

×
×

注册

官方QQ群

扫描上面二维码加微信群

官方QQ群

jQuery/js讨论群
群号:642649996
Css3+Html5讨论群
群号:322131262

加群请备注:从官网了解到