Skip to content

Commit 98a1a6e

Browse files
committed
hover to zoom
1 parent 7de338b commit 98a1a6e

File tree

1 file changed

+82
-10
lines changed

1 file changed

+82
-10
lines changed

pages/Getting started with EarthCODE/Deep Dive into EarthCODE.md

Lines changed: 82 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,37 @@ order: 4
1414
As described in [Step 1: Understand EarthCODE Terminology](/Getting%20started%20with%20EarthCODE/#step-1-understand-earthcode-terminology) EarthCODE provides an integrated ecosystem designed to support scientists through the full lifecycle of doing Open Science. EarthCODE was designed around supporting the work of scientists and developers from ESRIN, the ESA Science Clusters, the ESA Science Hub, and EC and ESA- Funded Activities.
1515

1616
A detailed concept of what EarthCODE is and the different actors involved can be seen in the figure below:
17-
18-
19-
<div class="zoom-container">
17+
<!--
18+
:::tip note to self, which one is better?
19+
Need to make this bigger - and zoomable
20+
Can we make it clickable
21+
::: -->
22+
<!-- ![EarthCODE Concept](/img/terms/earthcode-concept.svg)
23+
24+
V2 -->
25+
<!-- <div class="zoom-container">
2026
<img src="/img/terms/earthcode-conceptv2.svg" alt="Zoomed image" class="zoom-image" />
2127
</div>
2228
2329
<style>
24-
.zoom-container {
30+
.zoom-container {
2531
width: fit-content;
2632
height: fit-content;
2733
overflow: hidden;
2834
position: relative;
29-
cursor: zoom-in;
3035
}
36+
3137
.zoom-image {
3238
width: 100%;
3339
height: auto;
3440
transition: transform 0.3s ease;
3541
transform-origin: center center;
3642
}
37-
.zoom-container:hover {
38-
cursor: zoom-in;
39-
}
43+
4044
.zoom-container:hover .zoom-image {
41-
transform: scale(2);
45+
transform: scale(1.8);
4246
}
47+
4348
.zoom-container {
4449
--x: 50%;
4550
--y: 50%;
@@ -49,9 +54,76 @@ A detailed concept of what EarthCODE is and the different actors involved can be
4954
}
5055
5156
</style>
57+
<script setup>
58+
if (typeof window !== 'undefined') {
59+
document.addEventListener('mousemove', function (e) {
60+
document.querySelectorAll('.zoom-container').forEach(container => {
61+
const rect = container.getBoundingClientRect();
62+
const x = ((e.clientX - rect.left) / rect.width) * 100;
63+
const y = ((e.clientY - rect.top) / rect.height) * 100;
64+
container.style.setProperty('--x', `${x}%`);
65+
container.style.setProperty('--y', `${y}%`);
66+
});
67+
});
68+
}
69+
</script> -->
70+
71+
:::tip
72+
Hover to zoom
73+
:::
74+
<div class="zoom-wrapper">
75+
<div class="zoom-container">
76+
<img src="/img/terms/earthcode-conceptv2.svg" class="zoom-image" alt="Zoom preview" />
77+
</div>
78+
</div>
79+
80+
<style>
81+
.zoom-wrapper {
82+
position: relative;
83+
display: inline-block;
84+
padding: 20px; /* Sensitivity margin */
85+
--x: 50%;
86+
--y: 50%;
87+
cursor: zoom-in;
88+
89+
}
90+
.zoom-container {
91+
overflow: hidden;
92+
position: relative;
93+
width: fit-content;
94+
height: fit-content;
95+
cursor: zoom-in;
96+
}
5297

53-
<!-- ![EarthCODE Concept](/img/terms/earthcode-conceptv2.svg) -->
98+
.zoom-image {
99+
display: block;
100+
width: 100%;
101+
height: auto;
102+
transition: transform 0.3s ease;
103+
transform-origin: var(--x) var(--y);
104+
}
105+
106+
.zoom-wrapper:hover .zoom-image {
107+
transform: scale(1.8); /* zoom factor */
108+
}
109+
</style>
110+
<script setup>
111+
if (typeof window !== 'undefined') {
112+
document.addEventListener('mousemove', (e) => {
113+
document.querySelectorAll('.zoom-wrapper').forEach(wrapper => {
114+
const rect = wrapper.getBoundingClientRect();
115+
const x = ((e.clientX - rect.left) / rect.width) * 100;
116+
const y = ((e.clientY - rect.top) / rect.height) * 100;
117+
// zoom jumps handle/clamp
118+
if (x >= 0 && x <= 100 && y >= 0 && y <= 100) {
119+
wrapper.style.setProperty('--x', `${x}%`);
120+
wrapper.style.setProperty('--y', `${y}%`);
121+
}
122+
});
123+
});
124+
}
54125

126+
</script>
55127

56128

57129
In summary, EarthCODE provides the following:

0 commit comments

Comments
 (0)