Fix issue where SVG filter animations don't run in Chrome #44
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed that when using
@svg-filter
where the filter contains an animation, the animation does not work in Chrome or Opera.Example of animated svg filter using
<animate />
:The previous implementation creates and references the SVG using
URL.createObjectURL()
, however it seems that these browsers do not support filter animations when referenced from external SVG files. They do however work perfectly when the SVG is added directly to the DOM.This change adds the SVGs to the document body and references the filter ids directly instead of using
URL.createObjectURL()
. Right now they are added to a container<div>
withdisplay: none;
to prevent any changes to the layout.Unfortunately this isn't supported well by Firefox (it seems that no solution fits all browsers 😓), however it does support embedding the SVG directly into the CSS as a data URI (even with animations!), so this is used for Firefox browsers.
typeof InstallTrigger !== 'undefined';
is used for the firefox check as this seemed like the neatest thing I could think of. Please let me know if you think this is too messy or if you have any other ideas for this.I've tested this in Chrome, Opera and Firefox using the css-doodle.github.io project locally.
I really love this project and I just wanted to say thank you for your contributions to it!