var width = 0;
var height = 0;
if (document.documentElement &&
typeof document.documentElement.clientWidth === "number")
{
width = document.documentElement.clientWidth;
height = document.documentElement.clientHeight;
}
else if (document.body && typeof document.body.clientWidth === "number")
{
width = document.body.clientWidth;
height = document.body.clientHeight;
}
else if (typeof window.innerWidth === "number")
{
width = window.innerWidth - 18;
height = window.innerHeight - 18;
}
return { width: width, height: height };
};
return function () {
// Calculate the Height/Width of the component
var componentSize = getcomponentSize(component);
// Calculate the Viewport Height/Width
var viewportSize = getViewportSize();
// Calculate the Page Scrolling
var pageScroll = getPageScrolling();
// Calculate the coordinates to center component
var pageX =
pageScroll.scrollX + ((viewportSize.width - componentSize.width) / 2);
var pageY =
pageScroll.scrollY + ((viewportSize.height - componentSize.height) / 2);
// Update component Window coordinates
component.style.top = pageY + "px";
component.style.left = pageX + "px";
};
};
return { width: component.offsetWidth, height: component.offsetHeight };
};