-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
44 lines (42 loc) · 1.43 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function switchPage(page) {
let pageName = page.dataset.page;
let path = location.href.split("/").slice(-1);
if(pageName != path) {
window.location.href=pageName;
}
}
function resizeTitle() {
const targetHeight = 1440;
const targetWidth = 2560;
const h = window.innerHeight;
const w = window.innerWidth;
const zoomH = h / targetHeight;
const zoomW = w / targetWidth;
const zoomH2 = w / targetHeight;
const zoomW2 = h / targetWidth;
let mh = (targetHeight - h) / 2;
let mw = (targetWidth - w) / 2;
let mh2os = targetWidth / 2 - w / 2;
let mw2os = targetHeight / 2 - h / 2;
const root = document.getElementById('body');
if (root) {
if (w > h) {
mw = -mw;
mh = -mh;
if (w * (9 / 16) >= h) {
root.style.transform = `translate(${mw}px, ${mh}px) scale(${zoomH},${zoomH})`;
}
if (w * (9 / 16) < h) {
root.style.transform = `translate(${mw}px, ${mh}px) scale(${zoomW},${zoomW})`;
}
} else {
mw2os = -mw2os;
if (h * (9 / 16) >= w) {
root.style.transform = `rotate(90deg) translate(${mw2os}px, ${mh2os}px) scale(${zoomH2},${zoomH2})`;
}
if (h * (9 / 16) < w) {
root.style.transform = `rotate(90deg) translate(${mw2os}px, ${mh2os}px) scale(${zoomW2},${zoomW2})`;
}
}
}
}