I have an JPG with an SVG mask:
<img src="thumb.jpg" class="thumb">
.thumb {
mask: url('mask.svg#mask');
-webkit-mask-image: url('mask.svg');
}
So far, so good.
What I would like is for the element of the SVG to animate when the image is hovered. With a normal SVG this would be easy enough as I could target the elements with CSS. With a mask I'm not so sure. I can't target the elements directly as they are not present in the DOM.
#thumb-mask {
&:hover {
path {
opacity: 0 !important;
}
}
}
I have tried onmouseover events inside the SVG but they don't appear be getting triggered.
<path ...
onmouseover="evt.target.setAttribute('opacity', '0.5');"
onmouseout="evt.target.setAttribute('opacity', '1')" />
Is this even possible?
Edit: If I bring the SVG inline I still can't target it when the image is hovered. Also I have multiple .thumb
s, so I would need multiple SVGs if they are to animate independently (see my comment below).