From 07dfc32d1425a84f8c0cd838e0717fd93fe7b7e1 Mon Sep 17 00:00:00 2001 From: sienori Date: Sat, 23 Dec 2017 00:00:24 +0900 Subject: [PATCH] add a setting the top and bottom left position --- simple-translate/simple-translate.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/simple-translate/simple-translate.js b/simple-translate/simple-translate.js index f3ecfcf..91fb72d 100644 --- a/simple-translate/simple-translate.js +++ b/simple-translate/simple-translate.js @@ -51,14 +51,27 @@ function checkLang() { //ボタンを表示 function popupButton(e) { - let position; + let topPosition = 10; + let leftPosition = 10; let buttonSize = S.get().buttonSize; - if (S.get().buttonPosition == "rightUp") position = (-1 * buttonSize) - 10; - else if (S.get().buttonPosition == "rightDown") position = 10; + switch (S.get().buttonPosition) { + case "rightUp": + topPosition = (-1 * buttonSize) - 10; + break; + case "rightDown": + break; + case "leftUp": + topPosition = (-1 * buttonSize) - 10; + leftPosition = (-1 * buttonSize) - 10; + break; + case "leftDown": + leftPosition = (-1 * buttonSize) - 10; + break; + } - button.style.left = e.clientX + 10 + 'px'; - button.style.top = e.clientY + position + 'px'; + button.style.left = e.clientX + leftPosition + 'px'; + button.style.top = e.clientY + topPosition + 'px'; button.style.width = S.get().buttonSize + "px"; button.style.height = S.get().buttonSize + "px"; button.style.display = 'block';