Skip to content

Commit 4dfb663

Browse files
authored
Merge pull request #15 from webduinoio/improvement/5901
Improvement/5901
2 parents deadcd7 + 32a2730 commit 4dfb663

File tree

2 files changed

+14
-42
lines changed

2 files changed

+14
-42
lines changed

Diff for: js/main-en.js

+3-17
Original file line numberDiff line numberDiff line change
@@ -379,22 +379,8 @@
379379
}
380380

381381
// 處理中間圖片跟隨視窗大小移動位置
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`;
395-
}
396-
397-
window.addEventListener('resize', screenRotate);
398-
screenRotate();
382+
window.addEventListener('resize', () => {
383+
location.reload();
384+
});
399385

400386
}();

Diff for: js/main.js

+11-25
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,23 +378,9 @@
378378
kebbi.addEventListener('touchstart', target);
379379
}
380380

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`;
395-
}
396-
397-
window.addEventListener('resize', screenRotate);
398-
screenRotate();
381+
// 處理中間圖片跟隨視窗大小移動位置
382+
window.addEventListener('resize', () => {
383+
location.reload();
384+
});
399385

400386
}();

0 commit comments

Comments
 (0)