Dennis
Dennis

Reputation: 1101

SnapSVG: Remove mask from an element (unmask)

I have my JS code in which I use Snap SVG. At some point I use

element.attr({mask:maskelement});

In that snippet, element and maskelement are two elements inside my svg.

Now I want to remove the mask. What would be the correct code that achieves this?

Upvotes: 4

Views: 1598

Answers (2)

vusiliyK
vusiliyK

Reputation: 33

I had a similar problem. For some reason,

element.attr('mask', null');

does not work, so to make it work, I had to do:

element.node.removeAttribute('mask');

Upvotes: 0

mjkaufer
mjkaufer

Reputation: 4216

I found an answer here, although I feel it's not the best answer.

Basically, you set the mask's display property to none with the following code

maskelement.attr("display", "none");

Although the SVG looks like there's no more mask, it doesn't truly remove the mask. I think there's a better answer available.

Upvotes: 1

Related Questions