Hmmm, I managed to animate something inside a <use> element.
It's probably a hack, I don't know.
This is what I did in the HTML. In the head of this HTML I include the necessary 'svg4everybody' script files. In the HTML I put the SVG with a <use> tag.
Like so:
<html>
<head>
...
<script src="js/svg4everybody.legacy.min.js"></script>
<script>
svg4everybody({polyfill: true});
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
</head>
<body>
<div class="wrapper">
<div class="toptaak_icon"><svg class="alkmaar_icon" role="presentation"><use xlink:href="img/alkmaar_iconen.svg#maaltijdverzorging"></use></svg></div>
</div>
<script>
...
</script>
</body>
This SVG file contains around 60 icons, all defined as a <symbol> with a unique ID, and I only use one of these in this example.
Now comes the weird part.
I use bits of the javascript you referred to on plunker: http://plnkr.co/edit/LneUEK?p=preview
This is how that javascript (inside the HTML document) looks like:
$(function(){
var container = $("#foo");
var svgUrl = "foo.svg";
$.get(svgUrl)
.then(injectSvg)
.always(startAnimation);
function injectSvg(xmlDoc) {
var svg = $(xmlDoc).find("svg");
container.append(svg);
}
function startAnimation() {
var tl = new TimelineMax();
var icon = $('#maaltijd');
var show = $('.toptaak_icon');
tl.set(show, {autoAlpha:1});
tl.from(icon,0.5,{scaleX:0.5, scaleY:0, transformOrigin:"50% 100%", ease:Elastic. easeOut.config( 1, 0.3)});
}
});
The first part of this script (before 'function startAnimation()' ) makes it happen.
What is weird though, is that there is no element with an id of 'foo' in the HTML, there isn't even a SVG file named 'foo.svg'.
But when I delete those lines (everything before 'function startAnimation()' ) nothing is animated, and the SVG just renders as a static icon on screen.
So somehow, these lines are needed although they refer to elements that are not present.
You can see it working here: https://woohoodesign.nl/svg/raf/icon-preview.html
I don't know exactly how I got this working (my javascript skills are limited), but it is working.