Skip to content

Instantly share code, notes, and snippets.

@serivires
Last active December 31, 2015 03:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save serivires/7928983 to your computer and use it in GitHub Desktop.
Save serivires/7928983 to your computer and use it in GitHub Desktop.
function ZB_layerAction(name, status) {
var obj = document.getElementById(name);
var _tmpx, _tmpy, marginx, marginy;
_tmpx = event.clientX + parseInt(obj.offsetWidth);
_tmpy = event.clientY + parseInt(obj.offsetHeight);
_marginx = document.body.clientWidth - _tmpx;
_marginy = document.body.clientHeight - _tmpy;
var scrollLeft = (document.documentElement && document.documentElement.scrollLeft) || document.body.scrollLeft;
var scrollTop = (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop;
if (_marginx < 0)
_tmpx = event.clientX + scrollLeft + _marginx;
else
_tmpx = event.clientX + scrollLeft;
if (_marginy < 0)
_tmpy = event.clientY + scrollTop + _marginy + 20;
else
_tmpy = event.clientY + scrollTop;
obj.style.left = (_tmpx - 13) + "px";
obj.style.top = (_tmpy - 12) + "px";
if (status == 'visible') {
if (select_obj) {
select_obj.style.visibility = 'hidden';
select_obj = null;
}
select_obj = obj;
} else {
select_obj = null;
}
obj.style.visibility = status;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment