Newer
Older
alt="Social vulnerability and water insecurity"
<img
ref="bwHeroImage"
id="bw-title-image"
:class="{ mobile: mobileView }"
alt="Social vulnerability and water insecurity (grayscale)"
/>
<!-- Using svg masks with a circle shape to reveal color image where circles are on top of bw -->
<svg ref="overlay" id="overlay" xmlns="http://www.w3.org/2000/svg">
<defs>
<mask id="circleMask">
<rect width="100%" height="100%" fill="white" />
<circle cx="100" cy="100" r="50" fill="black" />
<circle cx="200" cy="150" r="30" fill="black" />
<circle cx="300" cy="250" r="90" fill="black" />
<circle cx="600" cy="200" r="50" fill="black" />
<circle cx="700" cy="550" r="100" fill="black" />
<circle cx="800" cy="200" r="70" fill="black" />
<circle cx="70" cy="310" r="50" fill="black" />
<circle cx="500" cy="450" r="130" fill="black" />
<circle cx="420" cy="180" r="40" fill="black" />
<circle cx="600" cy="200" r="75" fill="black" />
<circle cx="700" cy="350" r="130" fill="black" />
<circle cx="800" cy="20" r="110" fill="black" />
</mask>
How societal factors shape vulnerability to water insecurity
const overlay = ref(null);
const updateSvgDimensions = () => {
if (heroImage.value && bwHeroImage.value && overlay.value) {
const { width, height } = heroImage.value.getBoundingClientRect();
overlay.value.setAttribute('width', width);
overlay.value.setAttribute('height', height);
bwHeroImage.value.style.width = `${width}px`;
bwHeroImage.value.style.height = `${height}px`;
bwHeroImage.value.style.top = '0';
bwHeroImage.value.style.left = '0';
}
};
onMounted(() => {
updateSvgDimensions();
window.addEventListener('resize', updateSvgDimensions);
});
watch(mobileView, () => {
updateSvgDimensions();
});
<style lang="scss" scoped>
#grid-container {
display: grid;
#image-container {
position: relative;
width: 100%;
}
#title-image,
#bw-title-image {
width: 100%;
#bw-title-image {
filter: grayscale(100%);
position: absolute;
top: 0;
left: 0;
pointer-events: none; /* Ensure the grayscale image doesn't interfere with other interactions */
mask: url(#circleMask); /* Apply the SVG mask */
#overlay {
position: absolute;
top: 0;
left: 0;
pointer-events: none; /* Ensure the SVG overlay doesn't interfere with other interactions */
}
padding: 20px;
box-sizing: border-box;
h1 {
margin: -20px 20px;
color: white;
text-align: left; /* Optional: Align text to the left */
}
text-align: left; /* Optional: Align text to the left */