Skip to content

Commit 0712b06

Browse files
committed
Finalize customScaleCalc /
Tidy up project / Maybe use Webpack in future
1 parent c75b8fa commit 0712b06

10 files changed

Lines changed: 27 additions & 56 deletions

JS/customScaleCalc.js

Lines changed: 3 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

JS/customScaleCalc.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Style/_base-sections.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
flex-flow: row nowrap;
1818
justify-content: center;
1919
align-items: center;
20-
// padding: 0 10px 10px;
2120
margin-bottom: 5px;
22-
// border: 1px solid red;
2321

2422
.section-header {
2523
width: 100%;

Style/_config.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
}
77

88
body {
9-
// background: rgb(19, 20, 21);
109
background-color: rgb(27, 29, 31);
1110
color: rgb(237, 232, 232);
12-
// width: 100%;
1311
height: 100vh;
1412
display: flex;
1513
flex-flow: column nowrap;

Style/_customScaleCalc.scss

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
.default-properties {
2-
// width: 300vw;
32
width: 100%;
43
background-color: rgb(27, 29, 31);
5-
// box-shadow: 0 0 10px 10px rgba(13, 13, 13, 0.732);
4+
transform-origin: top;
65
}
76

87
.custom-scale-calc {
9-
// position: absolute;
10-
// right: 50vw;
11-
// transform: scale(0.5) rotate(90deg) translate(-50%, -53%);
12-
// width: 140vh;
13-
// transform-origin: left-top;
14-
// height: 500px !important;
15-
transform-origin: center;
168
position: relative;
17-
top: 24vh;
18-
width: 1000px;
9+
width: 1000px !important;
1910
}

Style/_edit-section.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
.edit-section {
22
width: 400px;
3-
// height: 80%;
43
height: 490px;
54
border-radius: 10px;
65
overflow: hidden;
@@ -10,6 +9,7 @@
109
direction: rtl;
1110
border: 1px solid black;
1211
box-shadow: 0 0 3px 3px rgba(0, 0, 0, 0.1);
12+
margin: 0 0.6vw;
1313

1414
.edit-list-container {
1515
min-height: 300px;

Style/_input-output-sections.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
border: 1px solid rgb(0, 0, 0);
55
border-radius: 10px;
66
overflow: hidden;
7-
// height: 80%;
87
height: 490px;
98
position: relative;
109
padding-top: 30px;
1110
box-shadow: 0 0 3px 3px rgba(0, 0, 0, 0.1);
11+
margin: 0 0.6vw;
1212

1313
.input-list,
1414
.output-list {

Style/style.css

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,12 @@ body {
4242
.default-properties {
4343
width: 100%;
4444
background-color: rgb(27, 29, 31);
45+
transform-origin: top;
4546
}
4647

4748
.custom-scale-calc {
48-
transform-origin: center;
4949
position: relative;
50-
top: 24vh;
51-
width: 1000px;
50+
width: 1000px !important;
5251
}
5352

5453
@keyframes shake {
@@ -139,6 +138,7 @@ body {
139138
position: relative;
140139
padding-top: 30px;
141140
box-shadow: 0 0 3px 3px rgba(0, 0, 0, 0.1);
141+
margin: 0 0.6vw;
142142
}
143143
.input-section .input-list,
144144
.input-section .output-list,
@@ -230,6 +230,7 @@ body {
230230
direction: rtl;
231231
border: 1px solid black;
232232
box-shadow: 0 0 3px 3px rgba(0, 0, 0, 0.1);
233+
margin: 0 0.6vw;
233234
}
234235
.edit-section .edit-list-container {
235236
min-height: 300px;

Style/style.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

TS/customScaleCalc.ts

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,43 @@ const customScaleDiv = document.querySelector(
22
".custom-scale-div"
33
) as HTMLElement;
44

5+
// CustomScaleCalc
6+
// This is a method I created myself, and I find it very interesting. I named it customScaleCalc.
7+
// Adjusts the scale and rotation of the element based on the window size.
8+
// For landscape displays, scales the element by height for optimal viewing.
9+
// For portrait displays, rotates the element 90 degrees and scales down for mobile compatibility.
10+
// Ultimately, in the mobile device's browser, the application is correctly displayed with a 90-degree rotation,
11+
// allowing devices with different sizes to use the program. Ensures the app looks good on any screen size by recalculating on window resize.
12+
513
const customScaleCalc = () => {
614
const pageWidth = window.innerWidth;
715
const pageHeight = window.innerHeight;
816

917
if (pageWidth > 270) {
1018
if (pageHeight > pageWidth) {
11-
// console.log(pageWidth, pageHeight);
12-
1319
customScaleDiv.classList.add("custom-scale-calc");
1420

15-
// let scale = 1 - ((pageHeight / pageWidth) * 0.2) / (900 / 477);
16-
17-
// customScaleDiv.style.transform = `scale(${scale}) rotate(90deg)`;
18-
19-
// customScaleDiv.classList.remove("custom-scale-calc");
20-
// customScaleDiv.style.transform = "";
21-
2221
let scaleValue = 0;
23-
2422
if (pageHeight / pageWidth > 1130 / 780) {
2523
scaleValue = (1 * pageWidth) / 695;
2624
} else {
2725
scaleValue = (0.7 * pageWidth) / 695;
2826
}
2927

30-
customScaleDiv.style.transform = `scale(${scaleValue}) rotate(90deg)`;
31-
customScaleDiv.style.display = "block";
32-
33-
// customScaleDiv.style.top = `${(pageHeight - 920 * scaleValue)/2}px`;
34-
35-
// customScaleDiv.style.transformOrigin = "top";
36-
37-
// console.log("scale", scale);
28+
customScaleDiv.style.transform = `scale(${scaleValue}) rotate(90deg) translate(50%, -50%)`;
29+
customScaleDiv.style.top = `${
30+
(pageHeight - 1000 * scaleValue) / 2
31+
}px`;
3832
} else {
3933
customScaleDiv.classList.remove("custom-scale-calc");
40-
// customScaleDiv.style.transform = "";
34+
4135
const scaleValue = (1 * pageHeight) / 695;
4236

4337
customScaleDiv.style.transform = `scale(${scaleValue})`;
44-
customScaleDiv.style.display = "block";
45-
customScaleDiv.style.transformOrigin = "top";
38+
customScaleDiv.style.width = `${pageWidth / scaleValue}px`;
4639
}
4740
}
4841
};
4942

5043
customScaleCalc();
5144
window.addEventListener("resize", customScaleCalc);
52-
53-
// Description: This is a method I created myself, and I find it very
54-
// interesting. I named it customScaleCalc. What it does is, when the
55-
// height of the screen is greater than the width (as in the case of some
56-
// smartphones), it rotates the screen by 90 degrees and scales down the
57-
// content with a certain ratio. Ultimately, in the mobile device's
58-
// browser,the application is correctly displayed with a 90-degree
59-
// rotation, allowing devices with different sizes to use the program.
60-
// This calculation of how to display the screen is performed.

0 commit comments

Comments
 (0)