vue-socials
Version:
Social media share buttons and counts for Vue.js
21 lines (19 loc) • 671 B
JavaScript
/**
* A simple function to get window client rect.
* It works with minimized windows, user zoom, and dual-screen.
* @link http://www.xtf.dk/2011/08/center-new-popup-window-even-on.html
*/
function getPopupClientRect(width, height) {
var systemZoom = window.innerWidth / window.screen.availWidth;
var finalWidth = width / systemZoom;
var finalHeight = height / systemZoom;
var left = (window.innerWidth - width) / 2 / systemZoom + window.screenLeft;
var top = (window.innerHeight - height) / 2 / systemZoom + window.screenTop;
return {
width: finalWidth,
height: finalHeight,
top: top,
left: left
};
}
export default getPopupClientRect;