Difference between revisions of "Team:SSTi-SZGD/js/btn"

(js btn)
 
m (add animate)
Line 1: Line 1:
 
$(function(){
 
$(function(){
 +
 +
//dispaly
 +
if($(window).scrollTop()!=0){
 +
$(".page_btn .btn_top").removeClass("fadeOutRight").addClass("fadeInRight");
 +
setTimeout(function(){
 +
$(".page_btn .btn_top").css("display","block");
 +
},500);
 +
}else{
 +
$(".page_btn .btn_top").removeClass("fadeInRight").addClass("fadeOutRight");
 +
setTimeout(function(){
 +
$(".page_btn .btn_top").css("display","none");
 +
},500);
 +
}
 +
 +
$(window).scroll(function(){
 +
if($(window).scrollTop()!=0){
 +
$(".page_btn .btn_top").removeClass("fadeOutRight").addClass("fadeInRight");
 +
setTimeout(function(){
 +
$(".page_btn .btn_top").css("display","block");
 +
},500);
 +
}else{
 +
$(".page_btn .btn_top").removeClass("fadeInRight").addClass("fadeOutRight");
 +
setTimeout(function(){
 +
$(".page_btn .btn_top").css("display","none");
 +
},500);
 +
}
 +
});
 
 
 
//hover
 
//hover
Line 21: Line 48:
 
$(".page_btn .btn_top").click(function(){
 
$(".page_btn .btn_top").click(function(){
 
 
$("html,body").animate({scrollTop: '0px'},800);
+
$("html,body").stop().animate({scrollTop: '0px'},800);
 
$(this).css("background-color","#fff");
 
$(this).css("background-color","#fff");
 
 

Revision as of 08:43, 2 August 2018

$(function(){

//dispaly if($(window).scrollTop()!=0){ $(".page_btn .btn_top").removeClass("fadeOutRight").addClass("fadeInRight"); setTimeout(function(){ $(".page_btn .btn_top").css("display","block"); },500); }else{ $(".page_btn .btn_top").removeClass("fadeInRight").addClass("fadeOutRight"); setTimeout(function(){ $(".page_btn .btn_top").css("display","none"); },500); }

$(window).scroll(function(){ if($(window).scrollTop()!=0){ $(".page_btn .btn_top").removeClass("fadeOutRight").addClass("fadeInRight"); setTimeout(function(){ $(".page_btn .btn_top").css("display","block"); },500); }else{ $(".page_btn .btn_top").removeClass("fadeInRight").addClass("fadeOutRight"); setTimeout(function(){ $(".page_btn .btn_top").css("display","none"); },500); } });

//hover $(".page_btn .btn_top").hover(function(){ $(this).css("background-color","#eee"); },function(){ $(this).css("background-color","#fff"); }); $(".page_btn .btn_language").hover(function(){ $(this).css("background-color","#eee"); },function(){ $(this).css("background-color","#fff"); }); $(".page_btn .btn_menu").hover(function(){ $(this).css("background-color","#eee"); },function(){ $(this).css("background-color","#fff"); });

//click $(".page_btn .btn_top").click(function(){

$("html,body").stop().animate({scrollTop: '0px'},800); $(this).css("background-color","#fff");

});

//touch $(".page_btn .btn_top").on("touchstart",function(){ $(this).css("background-color","#eee"); }); $(".page_btn .btn_top").on("touchend",function(){ $(this).css("background-color","#fff"); }); $(".page_btn .btn_language").on("touchstart",function(){ $(this).css("background-color","#eee"); }); $(".page_btn .btn_language").on("touchend",function(){ $(this).css("background-color","#fff"); }); $(".page_btn .btn_menu").on("touchstart",function(){ $(this).css("background-color","#eee"); }); $(".page_btn .btn_menu").on("touchend",function(){ $(this).css("background-color","#fff"); });

});