Note: While I understand that image masking can solve my issue, I prefer not to use it as it would require me to use my image as a background and could present accessibility challenges. I am specifically looking for solutions involving clip-path.
Issue: The <rect>
elements in my SVG file are not responding to changes in fillOpacity
or opacity
. These <rect>
elements need to be animated individually, so adjusting the opacity of the entire image/SVG simultaneously is not an option. I have attempted the fixes suggested here and here, but none of them have been successful.
This project involves React, and here is the HTML and CSS code in question:
img {
clip-path: url(#path-One);
height: 60vw;
}
<div>
<img src="https://images.unsplash.com/photo-1506399558188-acca6f8cbf41?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=2173&q=80" alt="Big Data" />
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1280.000000 673.000000">
<clipPath id="path-One" transform="scale(1.127, 1.127)">
<!-- Line 1: -->
<rect width="10vw" height="10vw" fillOpacity="0" />
<rect x="10vw" width="10vw" height="10vw" />
<rect x="20vw" width="10vw" height="10vw" />
<rect x="30vw" width="10vw" height="10vw" />
<rect x="40vw" width="10vw" height="10vw" />
<rect x="50vw" width="10vw" height="10vw" />
<rect x="60vw" width="10vw" height="10vw" />
<rect x="70vw" width="10vw" height="10vw" />
<rect x="80vw" width="10vw" height="10vw" />
<!-- Line 2: -->
<rect y="10vw" width="10vw" height="10vw" />
<rect x="10vw" y="10vw" width="10vw" height="10vw" />
<rect x="20vw" y="10vw" width="10vw" height="10vw" />
<rect x="30vw" y="10vw" width="10vw" height="10vw" />
<rect x="40vw" y="10vw" width="10vw" height="10vw" />
<rect x="50vw" y="10vw" width="10vw" height="10vw" />
<rect x="60vw" y="10vw" width="10vw" height="10vw" />
<rect x="70vw" y="10vw" width="10vw" height="10vw" />
<rect x="80vw" y="10vw" width="10vw" height="10vw" />
<!-- Line 3: -->
<rect y="20vw" width="10vw" height="10vw" />
<rect x="10vw" y="20vw" width="10vw" height="10vw" />
<rect x="20vw" y="20vw" width="10vw" height="10vw" />
<rect x="30vw" y="20vw" width="10vw" height="10vw" />
<rect x="40vw" y="20vw" width="10vw" height="10vw" />
<rect x="50vw" y="20vw" width="10vw" height="10vw" />
<rect x="60vw" y="20vw" width="10vw" height="10vw" />
<rect x="70vw" y="20vw" width="10vw" height="10vw" />
<rect x="80vw" y="20vw" width="10vw" height="10vw" />
<!-- Line 4: -->
<rect y="30vw" width="10vw" height="10vw" />
<rect x="10vw" y="30vw" width="10vw" height="10vw" />
<rect x="20vw" y="30vw" width="10vw" height="10vw" />
<rect x="30vw" y="30vw" width="10vw" height="10vw" />
<rect x="40vw" y="30vw" width="10vw" height="10vw" />
<rect x="50vw" y="30vw" width="10vw" height="10vw" />
<rect x="60vw" y="30vw" width="10vw" height="10vw" />
<rect x="70vw" y="30vw" width="10vw" height="10vw" />
<rect x="80vw" y="30vw" width="10vw" height="10vw" />
</clipPath>
</svg>
</div>