-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
40 lines (36 loc) · 1.14 KB
/
app.js
File metadata and controls
40 lines (36 loc) · 1.14 KB
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
let element = document.getElementById("personal_letter");
function isOutside() {
let bounding = element.getBoundingClientRect();
return bounding.bottom > (document.documentElement.clientHeight || window.innerHeight);
}
const makeSureTextIsVisible = () => {
if (
(document.documentElement.clientWidth || window.innerWidth) <= 750 ||
(document.documentElement.clientHeight || window.innerHeight) < 700
) {
if (element.style.fontSize != "24px") element.style.fontSize = "24px";
return;
}
let originalSize = getComputedStyle(element).fontSize;
let size = originalSize.match(/\d+/g).map(Number)[0];
while (!isOutside() && size < 26) {
size += 2;
element.style.fontSize = `${size}px`;
}
while (isOutside() && size > 18) {
size -= 2;
element.style.fontSize = `${size}px`;
}
};
let resizeTimer;
const debounceResize = () => {
clearTimeout(resizeTimer);
resizeTimer = setTimeout(makeSureTextIsVisible, 250);
};
window.addEventListener("load", debounceResize);
window.addEventListener("resize", debounceResize);
const logSocial = (category) => {
gtag("event", "Clicked", {
event_category: category,
});
};