From 2c57c66195a2c3a280fb33bf0a8f433d20650516 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Thu, 19 Dec 2024 04:09:31 +0300 Subject: [PATCH] Center share popup inside the browser window --- app/assets/javascripts/social_share_button.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/social_share_button.js b/app/assets/javascripts/social_share_button.js index 409b2c58a..34db84758 100644 --- a/app/assets/javascripts/social_share_button.js +++ b/app/assets/javascripts/social_share_button.js @@ -2,8 +2,8 @@ function openShareUrl(url, initialWidth = 640, initialHeight = 480) { const width = Math.max(100, Math.min(screen.width, initialWidth)); const height = Math.max(100, Math.min(screen.height, initialHeight)); - const left = (screen.width / 2) - (width / 2); - const top = (screen.height * 0.3) - (height / 2); + const left = screenLeft + ((outerWidth - width) / 2); + const top = screenTop + ((outerHeight - height) / 2); const opts = `width=${width},height=${height},left=${left},top=${top},menubar=no,status=no,location=no`; window.open(url, "popup", opts); -- 2.39.5