Skip to content

Commit 27bc897

Browse files
committed
Revert "refactor: ♻️ refactor code"
This reverts commit a10d2f2.
1 parent a10d2f2 commit 27bc897

File tree

2 files changed

+23
-28
lines changed

2 files changed

+23
-28
lines changed

js/main-en.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -378,16 +378,4 @@
378378
kebbi.addEventListener('touchstart', target);
379379
}
380380

381-
// 處理中間圖片跟隨視窗大小移動位置
382-
window.onresize = function () {
383-
watchChangeSize();
384-
}
385-
386-
function watchChangeSize() {
387-
const offsetWidth = document.documentElement.clientWidth;
388-
if (offsetWidth) {
389-
location.reload();
390-
}
391-
}
392-
393381
}();

js/main.js

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
});
8585
saveBtn.addEventListener('click', async function () {
8686
let t = new Date();
87-
list.time = `${t.getFullYear()}/${t.getMonth() * 1 + 1}/${t.getDate()} ${t.getHours()}:${t.getMinutes()}:${t.getSeconds()}`;
87+
list.time = `${t.getFullYear()}/${t.getMonth()*1+1}/${t.getDate()} ${t.getHours()}:${t.getMinutes()}:${t.getSeconds()}`;
8888
let write = await database.ref('/').push(list);
8989
popup.classList.add('show');
9090
let url = `${urlOrigin}${urlPath}#${write.key}`;
@@ -290,12 +290,12 @@
290290

291291
// 注意,小車一開始的中心點 y 座標,不等於畫面的中心點 y 座標。
292292
// 邊界在中心的周圍 1/3 小車寬/高的距離
293-
const kxCenter = kx + carSize.width / 2; // 車子中心點 x 座標
294-
const kyCenter = ky + carSize.height / 2; // 車子中心點 y 座標
295-
const leftSide = ww * 0.5 - carSize.width / 3; // 左邊界,小於這個值,判定車子移動到左邊
296-
const rightSide = ww * 0.5 + carSize.width / 3; // 右邊界,大於這個值,判定車子移動到右邊
297-
const topSide = oy + carSize.height / 6; // 上邊界,小於這個值,判定車子移動到上面
298-
const bottomSide = oy + 5 * carSize.height / 6; // 下邊界,小於這個值,判定車子移動到下面
293+
const kxCenter = kx + carSize.width/2; // 車子中心點 x 座標
294+
const kyCenter = ky + carSize.height/2; // 車子中心點 y 座標
295+
const leftSide = ww * 0.5 - carSize.width/3; // 左邊界,小於這個值,判定車子移動到左邊
296+
const rightSide = ww * 0.5 + carSize.width/3; // 右邊界,大於這個值,判定車子移動到右邊
297+
const topSide = oy + carSize.height/6; // 上邊界,小於這個值,判定車子移動到上面
298+
const bottomSide = oy + 5 * carSize.height/6; // 下邊界,小於這個值,判定車子移動到下面
299299

300300
if (kxCenter < leftSide) {
301301
if (!send.left) {
@@ -378,16 +378,23 @@
378378
kebbi.addEventListener('touchstart', target);
379379
}
380380

381-
// 處理中間圖片跟隨視窗大小移動位置
382-
window.onresize = function () {
383-
watchChangeSize();
381+
// 處理中間圖片跟隨視窗大小移動位置
382+
function screenRotate() {
383+
const kebbi = document.getElementById('svgKebbi');
384+
const circle = document.querySelector('.circle');
385+
const ww = content.offsetWidth;
386+
const wh = content.offsetHeight;
387+
const ox = (ww - kebbi.offsetWidth) / 2;
388+
const oy = (wh * 0.8 - kebbi.offsetHeight) / 2;
389+
kebbi.style.left = `${ox}px`;
390+
kebbi.style.top = `${oy}px`;
391+
circle.style.width = `${ww * 0.4}px`;
392+
circle.style.height = `${ww * 0.4}px`;
393+
circle.style.left = `${(ww - circle.offsetWidth) / 2}px`;
394+
circle.style.top = `${(wh * 0.8 - circle.offsetHeight) / 2}px`;
384395
}
385396

386-
function watchChangeSize() {
387-
const offsetWidth = document.documentElement.clientWidth;
388-
if (offsetWidth) {
389-
location.reload();
390-
}
391-
}
397+
window.addEventListener('resize', screenRotate);
398+
screenRotate();
392399

393400
}();

0 commit comments

Comments
 (0)