Skip to content

Commit ee9b758

Browse files
committed
Hide fidget toy arrow and text when model preview is hidden
1 parent 1ecce69 commit ee9b758

File tree

5 files changed

+65
-17
lines changed

5 files changed

+65
-17
lines changed

about.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
<div class="model-preview">
1313
<canvas class="webgl">
1414
</canvas>
15-
<img id="fidget-toy" src="../images/about/arrow_purple.svg" style="position: absolute; left: 190px; top: 300px;">
15+
<img id="fidget-toy-arrow" src="../images/about/arrow_purple.svg" style="position: absolute; left: 190px; top: 300px;">
16+
<h1 id="fidget-toy-text" class="fidget-toy">
17+
fidget<br>
18+
&nbsp;toy
19+
</h1>
1620
</img>
17-
<h1 class="fidget-toy">
18-
&nbsp;fidget<br>
19-
toy
20-
</h1>
2121
</div>
2222
<div class="padding logo-wrapper">
2323
<logo>

images/about/arrow.svg

Lines changed: 30 additions & 6 deletions
Loading

src/About.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { PortfolioItem } from '../src/PortfolioItem.js';
44
// Model previewer
55
import { ModelPreviewer } from '../src/ModelPreviewer.js';
66

7-
7+
let fidgettoytext = document.getElementById("fidget-toy-text");
8+
let fidgettoyarrow = document.getElementById("fidget-toy-arrow");
9+
let preview = document.querySelector('.model-preview');
810
let portfolioItems = [];
911

1012
portfolioItems.push(
@@ -24,5 +26,26 @@ Promise.all(promises).then(() => {
2426
// Dark mode
2527
const userPrefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
2628
if (userPrefersDark) {
27-
document.getElementById("fidget-toy").src="/images/about/arrow.svg";
29+
fidgettoyarrow.src="/images/about/arrow.svg";
30+
}
31+
32+
Update();
33+
34+
function Update() {
35+
requestAnimationFrame(() => Update()); // Only update when tab open
36+
37+
const isHidden = preview.style.width == `0px`;
38+
fidgettoytext.hidden = isHidden;
39+
fidgettoyarrow.hidden = isHidden;
40+
}
41+
42+
/*
43+
window.addEventListener('resize', onWindowResize);
44+
onWindowResize();
45+
46+
function onWindowResize() {
47+
if (!shouldDisplayPreview()) {
48+
fidgettoy.hidden = false;
49+
}
2850
}
51+
*/

src/ModelPreviewer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class ObjectPicker {
5858
}
5959
}
6060

61-
function shouldDisplayPreview() {
61+
export function shouldDisplayPreview() {
6262
return ((window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth) > 800 &&
6363
((window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight) - 241 - 65) >= 386);
6464
}

styles.css

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -915,11 +915,12 @@ overlay {
915915
.fidget-toy
916916
{
917917
position: absolute;
918-
left: 275px;
919-
top: 298px;
920-
font-size: 20px;
918+
left: 265px;
919+
top: 288px;
920+
font-size: 24px;
921921
color: #f8cda8;
922922
transform: rotate(-10deg);
923+
font-family: 'Gloria Hallelujah';
923924
}
924925

925926
/* Dark Mode */

0 commit comments

Comments
 (0)