/* JQuery real position plugin
* Methods:
* $.visibleLeft(): returns the distance between the left window edge and current element
* $.visibleTop(): returns the distance between the top window edge and current element
*/
$.userTop=function (o) {
if (!o||!o.offsetParent) {
return 0;
} else {
var top=o.offsetTop;
do {
o=o.offsetParent;
top+=o.offsetTop;
} while (o.offsetParent);
}
return top;
}
$.userLeft=function(o) {
if (!o||!o.offsetParent) {
return 0;
} else {
var left=o.offsetLeft;
do {
o=o.offsetParent;
// top+=o.offsetLeft;
left+=o.offsetLeft;
} while (o.offsetParent);
}
return left;
}
$.fn.visibleTop = function() {
//multiple elements not anticipated, returns minimum
var current=-1;
this.each(function(){
//if current isnt defined, then assign it user left
//or if left is less than left so far
current=(current==-1||$.userTop(this)<current)?$.userTop(this):current;
});
return current;
}
$.fn.visibleLeft = function() {
/*Visible left does not work correctly
* there is a mistake top ? left ?
*
*/
//multiple elements not anticipated, returns minimum
var current=-1;
this.each(function(){
//if current isnt defined, then assign it user left
//or if left is less than left so far
current=(current==-1||$.userLeft(this)<current)?$.userLeft(this):current;
});
return current;
};