Template:UseFloats: Difference between revisions

Template page
mNo edit summary
mNo edit summary
Line 28: Line 28:
   }
   }


   function findDistanceX(out, in) {
   function findDistanceX(outobj, inobj) {
     var distx = 0;
     var distx = 0;


     if (in.offsetParent) {
     if (inobj.offsetParent) {
       while (in.offsetParent) {
       while (inobjoffsetParent) {
         if(in.offsetParent == out.offsetParent) {
         if(inobj.offsetParent == outobj.offsetParent) {
           break;
           break;
         }
         }


         distx += in.offsetLeft;
         distx += inobj.offsetLeft;
         in = in.offsetParent;
         inobj= inobj.offsetParent;
       }
       }
     } else if (in.x) {
     } else if (inobj.x) {
       distx = out.x - in.x;
       distx = outobj.x - inobj.x;
     }
     }


Line 47: Line 47:
   }
   }


   function findDistanceY(out, in) {
   function findDistanceY(outobj, inobj) {
     var disty = 0;
     var disty = 0;


     if (in.offsetParent) {
     if (inobj.offsetParent) {
       while (in.offsetParent) {
       while (inobjoffsetParent) {
         if(in.offsetParent == out.offsetParent) {
         if(inobj.offsetParent == outobj.offsetParent) {
           break;
           break;
         }
         }


         disty += in.offsetTop;
         disty += inobj.offsetTop;
         in = in.offsetParent;
         inobj = inobj.offsetParent;
       }
       }
     } else if (in.y) {
     } else if (inobj.y) {
       disty = out.y - in.y;
       disty = outobj.y - inobj.y;
     }
     }



Revision as of 18:47, 28 June 2006

<plainhtml>

<script type="text/javascript">

 var useFloats = true;
 function findRelPosX(obj) {
   var relleft = 0;
   if (obj.offsetParent) {
     relleft = obj.offsetLeft;
   } else if (obj.x) {
     relleft = obj.x;
   }
   return relleft;
 }
 function findRelPosY(obj) {
   var reltop = 0;
   if (obj.offsetParent) {
     reltop = obj.offsetTop;
   } else if (obj.y) {
     reltop = obj.y;
   }
   return reltop;
 }
 function findDistanceX(outobj, inobj) {
   var distx = 0;
   if (inobj.offsetParent) {
     while (inobjoffsetParent) {
       if(inobj.offsetParent == outobj.offsetParent) {
         break;
       }
       distx += inobj.offsetLeft;
       inobj= inobj.offsetParent;
     }
   } else if (inobj.x) {
     distx = outobj.x - inobj.x;
   }
   return distx;
 }
 function findDistanceY(outobj, inobj) {
   var disty = 0;
   if (inobj.offsetParent) {
     while (inobjoffsetParent) {
       if(inobj.offsetParent == outobj.offsetParent) {
         break;
       }
       disty += inobj.offsetTop;
       inobj = inobj.offsetParent;
     }
   } else if (inobj.y) {
     disty = outobj.y - inobj.y;
   }
   return disty;
 }
 function findPosX(obj)
 {
 	var curleft = 0;
 	if (obj.offsetParent)
 	{
 		while (obj.offsetParent)
 		{
 			curleft += obj.offsetLeft;
 			obj = obj.offsetParent;
 		}
 	}
 	else if (obj.x) {
 		curleft += obj.x;
       }
 	return curleft;
 }
 
 function findPosY(obj)
 {
 	var curtop = 0;
 	if (obj.offsetParent)
 	{
 		while (obj.offsetParent)
 		{
 			curtop += obj.offsetTop;
 			obj = obj.offsetParent;
 		}
 	}
 	else if (obj.y) {
 		curtop += obj.y;
       }
 	return curtop;
 }

</script>

</plainhtml>