YuhangYang (Talk | contribs) |
YuhangYang (Talk | contribs) (final) |
||
Line 5: | Line 5: | ||
if(window.location.search==""){ | if(window.location.search==""){ | ||
− | $(".btn_language").css("background-image","url( | + | $(".btn_language").css("background-image","url(img/language-en.png)"); |
}else{ | }else{ | ||
− | $(".btn_language").css("background-image","url( | + | $(".btn_language").css("background-image","url(img/language-zh.png)"); |
} | } | ||
Line 28: | Line 28: | ||
},500); | },500); | ||
} | } | ||
− | + | if($(window).height()<480){ | |
+ | $(".btn_top").css("display","none"); | ||
+ | } | ||
$(window).scroll(function(){ | $(window).scroll(function(){ | ||
if($(window).height()>=480&&$(window).scrollTop()>=16){ | if($(window).height()>=480&&$(window).scrollTop()>=16){ | ||
Line 42: | Line 44: | ||
} | } | ||
}); | }); | ||
− | + | ||
− | + | ||
− | + | ||
if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry|iPad/i.test(navigator.userAgent)){ | if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry|iPad/i.test(navigator.userAgent)){ | ||
$(".btn_top").css("bottom","180px"); | $(".btn_top").css("bottom","180px"); | ||
Line 60: | Line 60: | ||
$(".btn_top").css("bottom","155px"); | $(".btn_top").css("bottom","155px"); | ||
$(".btn_language").css("bottom","85px"); | $(".btn_language").css("bottom","85px"); | ||
+ | Cbtn_nav=0; | ||
+ | $(".btn_nav").css("display","none"); | ||
+ | $("html,body").css({"height":"auto","overflow":"auto"}); | ||
+ | var scrollTop=sessionStorage.getItem("scrollTop"); | ||
+ | $(document).scrollTop(scrollTop); | ||
} | } | ||
} | } | ||
Line 80: | Line 85: | ||
} | } | ||
if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry|iPad/i.test(navigator.userAgent)){ | if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry|iPad/i.test(navigator.userAgent)){ | ||
− | |||
$(".btn_top").css("bottom","180px"); | $(".btn_top").css("bottom","180px"); | ||
$(".btn_language").css("bottom","110px"); | $(".btn_language").css("bottom","110px"); | ||
$(".btn_menu").css("bottom","40px"); | $(".btn_menu").css("bottom","40px"); | ||
$(".btn_menu").css("display","block"); | $(".btn_menu").css("display","block"); | ||
− | |||
}else{ | }else{ | ||
if($(window).width()<751){ | if($(window).width()<751){ | ||
Line 96: | Line 99: | ||
$(".btn_top").css("bottom","155px"); | $(".btn_top").css("bottom","155px"); | ||
$(".btn_language").css("bottom","85px"); | $(".btn_language").css("bottom","85px"); | ||
+ | Cbtn_nav=0; | ||
+ | $(".btn_nav").css("display","none"); | ||
+ | $("html,body").css({"height":"auto","overflow":"auto"}); | ||
+ | var scrollTop=sessionStorage.getItem("scrollTop"); | ||
+ | $(document).scrollTop(scrollTop); | ||
} | } | ||
} | } | ||
Line 132: | Line 140: | ||
$(document).scrollTop(offset); | $(document).scrollTop(offset); | ||
}; | }; | ||
− | |||
Line 138: | Line 145: | ||
//滚动时保存滚动位置 | //滚动时保存滚动位置 | ||
− | sessionStorage.setItem("offsetTop",$(window).scrollTop()); | + | if(Cbtn_nav==0){ |
+ | sessionStorage.setItem("offsetTop",$(window).scrollTop()); | ||
+ | }else{ | ||
+ | var scrollTop=sessionStorage.getItem("scrollTop"); | ||
+ | sessionStorage.setItem("offsetTop",scrollTop); | ||
+ | } | ||
if(window.location.search==""){ | if(window.location.search==""){ | ||
Line 158: | Line 170: | ||
$(this).css("background-color","#eee"); | $(this).css("background-color","#eee"); | ||
Cbtn_nav=1; | Cbtn_nav=1; | ||
+ | setTimeout(function(){ | ||
+ | $("html,body").css({"height":"100%","overflow":"hidden"}); | ||
+ | },1200); | ||
+ | sessionStorage.setItem("scrollTop",$(window).scrollTop()); | ||
}else{ | }else{ | ||
$(".btn_nav").removeClass("fadeInDownBig").addClass("fadeOutUpBig"); | $(".btn_nav").removeClass("fadeInDownBig").addClass("fadeOutUpBig"); | ||
Line 165: | Line 181: | ||
$(this).css("background-color","#fff"); | $(this).css("background-color","#fff"); | ||
Cbtn_nav=0; | Cbtn_nav=0; | ||
+ | $("html,body").css({"height":"auto","overflow":"auto"}); | ||
+ | var scrollTop=sessionStorage.getItem("scrollTop"); | ||
+ | $(document).scrollTop(scrollTop); | ||
} | } | ||
Revision as of 02:36, 2 November 2018
$(function(){
$(".btn_nav").addClass("transition"); $(".btn_nav").find("*").addClass("transition");
if(window.location.search==""){ $(".btn_language").css("background-image","url(img/language-en.png)"); }else{ $(".btn_language").css("background-image","url(img/language-zh.png)"); }
//Translater var tran = new Translater({ lang:"en" });
//dispaly
if($(window).height()>480&&$(window).scrollTop()>=16){
$(".btn_top").removeClass("fadeOutRight").addClass("fadeInRight");
setTimeout(function(){
$(".btn_top").css("display","block");
},500);
}else{
$(".btn_top").removeClass("fadeInRight").addClass("fadeOutRight");
setTimeout(function(){
$(".btn_top").css("display","none");
},500);
}
if($(window).height()<480){
$(".btn_top").css("display","none");
}
$(window).scroll(function(){
if($(window).height()>=480&&$(window).scrollTop()>=16){
$(".btn_top").removeClass("fadeOutRight").addClass("fadeInRight");
setTimeout(function(){
$(".btn_top").css("display","block");
},500);
}else{
$(".btn_top").removeClass("fadeInRight").addClass("fadeOutRight");
setTimeout(function(){
$(".btn_top").css("display","none");
},500);
}
});
if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry|iPad/i.test(navigator.userAgent)){ $(".btn_top").css("bottom","180px"); $(".btn_language").css("bottom","110px"); $(".btn_menu").css("bottom","40px"); $(".btn_menu").css("display","block"); }else{ if($(window).width()<751){ $(".btn_top").css("bottom","180px"); $(".btn_language").css("bottom","110px"); $(".btn_menu").css("bottom","40px"); $(".btn_menu").css("display","block"); }else{ $(".btn_menu").css("display","none"); $(".btn_top").css("bottom","155px"); $(".btn_language").css("bottom","85px"); Cbtn_nav=0; $(".btn_nav").css("display","none"); $("html,body").css({"height":"auto","overflow":"auto"}); var scrollTop=sessionStorage.getItem("scrollTop"); $(document).scrollTop(scrollTop); } }
$(window).resize(function(){
if($(window).height()>=480&&$(window).scrollTop()>=16){
$(".btn_top").removeClass("fadeOutRight").addClass("fadeInRight");
setTimeout(function(){
$(".btn_top").css("display","block");
},500);
}else{
$(".btn_top").removeClass("fadeInRight").addClass("fadeOutRight");
setTimeout(function(){
$(".btn_top").css("display","none");
},500);
}
if($(window).height()<480){
$(".btn_top").css("display","none");
}
if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry|iPad/i.test(navigator.userAgent)){
$(".btn_top").css("bottom","180px");
$(".btn_language").css("bottom","110px");
$(".btn_menu").css("bottom","40px");
$(".btn_menu").css("display","block");
}else{
if($(window).width()<751){
$(".btn_top").css("bottom","180px");
$(".btn_language").css("bottom","110px");
$(".btn_menu").css("bottom","40px");
$(".btn_menu").css("display","block");
}else{
$(".btn_menu").css("display","none");
$(".btn_top").css("bottom","155px");
$(".btn_language").css("bottom","85px");
Cbtn_nav=0;
$(".btn_nav").css("display","none");
$("html,body").css({"height":"auto","overflow":"auto"});
var scrollTop=sessionStorage.getItem("scrollTop");
$(document).scrollTop(scrollTop);
}
}
});
//hover
$(".btn_top").hover(function(){
$(this).css("background-color","#eee");
},function(){
$(this).css("background-color","#fff");
});
$(".btn_language").hover(function(){
$(this).css("background-color","#eee");
},function(){
$(this).css("background-color","#fff");
});
$(".btn_menu").hover(function(){
$(this).css("background-color","#eee");
},function(){
$(this).css("background-color","#fff");
});
//click
$(".btn_top").click(function(){
$("html,body").stop().animate({scrollTop: '0px'},800); $(this).css("background-color","#fff");
});
//onload时,取出并滚动到上次保存位置 window.onload=function(){ var offset=sessionStorage.getItem("offsetTop"); $(document).scrollTop(offset); };
$(".btn_language").click(function(){
//滚动时保存滚动位置 if(Cbtn_nav==0){ sessionStorage.setItem("offsetTop",$(window).scrollTop()); }else{ var scrollTop=sessionStorage.getItem("scrollTop"); sessionStorage.setItem("offsetTop",scrollTop); }
if(window.location.search==""){ window.location.href+="?lang=cn"; }else{ window.location.href=""+window.location.href.split('?')[0]; }
});
var Cbtn_nav=0; $(".btn_menu").click(function(){
if(Cbtn_nav==0){ $(".btn_nav").removeClass("fadeOutUpBig").addClass("fadeInDownBig"); setTimeout(function(){ $(".btn_nav").css("display","block"); },500); $(this).css("background-color","#eee"); Cbtn_nav=1; setTimeout(function(){ $("html,body").css({"height":"100%","overflow":"hidden"}); },1200); sessionStorage.setItem("scrollTop",$(window).scrollTop()); }else{ $(".btn_nav").removeClass("fadeInDownBig").addClass("fadeOutUpBig"); setTimeout(function(){ $(".btn_nav").css("display","none"); },500); $(this).css("background-color","#fff"); Cbtn_nav=0; $("html,body").css({"height":"auto","overflow":"auto"}); var scrollTop=sessionStorage.getItem("scrollTop"); $(document).scrollTop(scrollTop); }
});
//touch
$(".btn_top").on("touchstart",function(){
$(this).css("background-color","#eee");
});
$(".btn_top").on("touchend",function(){
$(this).css("background-color","#fff");
});
$(".btn_language").on("touchstart",function(){
$(this).css("background-color","#eee");
});
$(".btn_language").on("touchend",function(){
$(this).css("background-color","#fff");
});
$(".btn_menu").on("touchstart",function(){
$(this).css("background-color","#eee");
});
$(".btn_menu").on("touchend",function(){
$(this).css("background-color","#fff");
});
});