YuhangYang (Talk | contribs) m (add animate) |
YuhangYang (Talk | contribs) (new btn) |
||
Line 2: | Line 2: | ||
//dispaly | //dispaly | ||
− | if($(window).scrollTop()!=0){ | + | if($(window).height()>480&&$(window).scrollTop()!=0){ |
− | $(" | + | $(".btn_top").removeClass("fadeOutRight").addClass("fadeInRight"); |
setTimeout(function(){ | setTimeout(function(){ | ||
− | $(" | + | $(".btn_top").css("display","block"); |
},500); | },500); | ||
}else{ | }else{ | ||
− | $(" | + | $(".btn_top").removeClass("fadeInRight").addClass("fadeOutRight"); |
setTimeout(function(){ | setTimeout(function(){ | ||
− | $(" | + | $(".btn_top").css("display","none"); |
},500); | },500); | ||
} | } | ||
$(window).scroll(function(){ | $(window).scroll(function(){ | ||
− | if($(window).scrollTop()!=0){ | + | console.log($(window).height()); |
− | $(" | + | if($(window).height()>480&&$(window).scrollTop()!=0){ |
+ | $(".btn_top").removeClass("fadeOutRight").addClass("fadeInRight"); | ||
setTimeout(function(){ | setTimeout(function(){ | ||
− | $(" | + | $(".btn_top").css("display","block"); |
},500); | },500); | ||
}else{ | }else{ | ||
− | $(" | + | $(".btn_top").removeClass("fadeInRight").addClass("fadeOutRight"); |
setTimeout(function(){ | setTimeout(function(){ | ||
− | $(" | + | $(".btn_top").css("display","none"); |
},500); | },500); | ||
} | } | ||
Line 29: | Line 30: | ||
//hover | //hover | ||
− | $(" | + | $(".btn_top").hover(function(){ |
$(this).css("background-color","#eee"); | $(this).css("background-color","#eee"); | ||
},function(){ | },function(){ | ||
$(this).css("background-color","#fff"); | $(this).css("background-color","#fff"); | ||
}); | }); | ||
− | $(" | + | $(".btn_language").hover(function(){ |
$(this).css("background-color","#eee"); | $(this).css("background-color","#eee"); | ||
},function(){ | },function(){ | ||
$(this).css("background-color","#fff"); | $(this).css("background-color","#fff"); | ||
}); | }); | ||
− | $(" | + | $(".btn_menu").hover(function(){ |
$(this).css("background-color","#eee"); | $(this).css("background-color","#eee"); | ||
},function(){ | },function(){ | ||
Line 46: | Line 47: | ||
//click | //click | ||
− | $(" | + | $(".btn_top").click(function(){ |
$("html,body").stop().animate({scrollTop: '0px'},800); | $("html,body").stop().animate({scrollTop: '0px'},800); | ||
$(this).css("background-color","#fff"); | $(this).css("background-color","#fff"); | ||
+ | |||
+ | }); | ||
+ | |||
+ | 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; | ||
+ | }else{ | ||
+ | $(".btn_nav").removeClass("fadeInDownBig").addClass("fadeOutUpBig"); | ||
+ | setTimeout(function(){ | ||
+ | $(".btn_nav").css("display","none"); | ||
+ | },500); | ||
+ | $(this).css("background-color","#fff"); | ||
+ | Cbtn_nav=0; | ||
+ | } | ||
}); | }); | ||
//touch | //touch | ||
− | $(" | + | $(".btn_top").on("touchstart",function(){ |
$(this).css("background-color","#eee"); | $(this).css("background-color","#eee"); | ||
}); | }); | ||
− | $(" | + | $(".btn_top").on("touchend",function(){ |
$(this).css("background-color","#fff"); | $(this).css("background-color","#fff"); | ||
}); | }); | ||
− | $(" | + | $(".btn_language").on("touchstart",function(){ |
$(this).css("background-color","#eee"); | $(this).css("background-color","#eee"); | ||
}); | }); | ||
− | $(" | + | $(".btn_language").on("touchend",function(){ |
$(this).css("background-color","#fff"); | $(this).css("background-color","#fff"); | ||
}); | }); | ||
− | $(" | + | $(".btn_menu").on("touchstart",function(){ |
$(this).css("background-color","#eee"); | $(this).css("background-color","#eee"); | ||
}); | }); | ||
− | $(" | + | $(".btn_menu").on("touchend",function(){ |
$(this).css("background-color","#fff"); | $(this).css("background-color","#fff"); | ||
+ | }); | ||
+ | |||
+ | //Navigation | ||
+ | $(".btn_nav li a").eq(0).addClass("active"); | ||
+ | |||
+ | // | ||
+ | if($(window).height()<=480){ | ||
+ | $(".btn_top").css("display","none"); | ||
+ | } | ||
+ | $(window).resize(function(){ | ||
+ | if($(window).height()<=480){ | ||
+ | $(".btn_top").css("display","none"); | ||
+ | } | ||
}); | }); | ||
}); | }); |
Revision as of 08:35, 3 August 2018
$(function(){
//dispaly if($(window).height()>480&&$(window).scrollTop()!=0){ $(".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); }
$(window).scroll(function(){ console.log($(window).height()); if($(window).height()>480&&$(window).scrollTop()!=0){ $(".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); } });
//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");
});
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; }else{ $(".btn_nav").removeClass("fadeInDownBig").addClass("fadeOutUpBig"); setTimeout(function(){ $(".btn_nav").css("display","none"); },500); $(this).css("background-color","#fff"); Cbtn_nav=0; }
});
//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"); });
//Navigation $(".btn_nav li a").eq(0).addClass("active");
// if($(window).height()<=480){ $(".btn_top").css("display","none"); } $(window).resize(function(){ if($(window).height()<=480){ $(".btn_top").css("display","none"); } });
});