JS代码 是否显示横竖条

来源:互联网 发布:麻将源码 编辑:程序博客网 时间:2024/04/24 02:21
  1.         //是否显示横竖条  
  2.         if (this.config["bar_dis"] == true) {  
  3.             if (!$("#vline").attr("id")) {  
  4.                 vLine = "<div id='vline' style='background-color:"+this.config["bar_color"]+";height:100%;width:1px;position:absolute;top:0px;left:" + (_point.x) + "px;'/>";  
  5.                 $(vLine).appendTo("body");  
  6.             } else {  
  7.                 $(vLine).css("left",(_point.x) + "px");  
  8.                 vLine.show();  
  9.             }  
  10.             if (!$("#hline").attr("id")) {  
  11.                 var hLine = "<div id='hline' style='overflow:hidden;background-color:"+this.config["bar_color"]+";height:1px;width:100%;position:absolute;left:0px;top:" + (_point.y ) + "px;'/>";  
  12.                  $(hLine).appendTo("body");  
  13.             } else {  
  14.                 $("#hline").css("top",(_point.y ) + "px");  
  15.                 hLine.show();  
  16.             }  
  17.         }  
  18.         this.hideFocus();  
  19.         return true;  
  20.     },  hideFocus:function() {//隐藏焦点效果  
  21.         if (paper != null) {  
  22.             var circle = paper.circle(25, 25, 30);  
  23.             circle.attr("stroke"this.config["circle_color"]);  
  24.             circle.attr("stroke-width", 1);  
  25.             var anim = Raphael.animation({  
  26.                 r: 5  
  27.             }, 900, nullfunction(){  
  28.                 this.locationTimer = setTimeout(function(){  
  29.                     $("#canvas").hide(); //焦点  
  30.                     $("#vline").hide();  //横条  
  31.                     $("#hline").hide();  //竖条  
  32.                     clearTimeout(this.locationTimer);  
  33.                 }, 500);  
  34.             });  
  35.             circle.animate(anim);  
  36.         } else {  
  37.             this.locationTimer = setTimeout(function(){  
  38.                 $("#canvas").hide(); //焦点  
  39.                 $("#vline").hide();  //横条  http://www.9oal.com/thread-7636-1-1.html
  40.                 $("#hline").hide();  //竖条  
  41.                 clearTimeout(this.locationTimer);  
  42.             }, 500);  
  43.         }  
  44.           
  45.     },mousePosition:function (e) {  
  46.         var x,y;  http://www.9oal.com/forum-37-1.html
  47.         var e = e||window.event;  
  48.         return {  
  49.             x:e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,  
  50.             y:e.clientY+document.body.scrollTop+document.documentElement.scrollTop  
  51.         }  
  52.     },elementPosition:function( oElement ) {  
  53.         var x2 = 0;  
  54.         var y2 = 0;  
  55.         var width = oElement.offsetWidth;  
  56.         var height = oElement.offsetHeight;  
  57.         var postion  = "";  
  58.         iftypeof( oElement.offsetParent ) != 'undefined' ){  
  59.             forvar posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ) {  
  60.                 posX += oElement.offsetLeft;  
  61.                 posY += oElement.offsetTop;        
  62.             }  
  63.             x2 = posX + width;  
  64.             y2 = posY + height;  
  65.             postion = [ posX, posY ,x2, y2];  
  66.         } else{  
  67.             x2 = oElement.x + width;  
  68.             y2 = oElement.y + height;  
  69.             postion = [ oElement.x, oElement.y, x2, y2];  
  70.         }  
  71.         var x = postion[0] + ((postion[2] - postion[0])/2);  
  72.         var y = postion[1] + ((postion[3] - postion[1])/2);  
  73.         return {"x":x,"y":y};  
  74.     }  
  75. }  
原创粉丝点击