Page 1 of 1

Anybody used web-animations polyfill?

Posted: 27 January 2021, 11:28
by shadowphiar
In a new project, I'm doing some experiments using element.animate() from the Web Animations api (a javascript equivalent to CSS animations). This is working very well on up-to-date browsers, but I'd also like to load the web-animations-js polyfill so that the same code works on older browsers (e.g. I have an iPad here with Safari iOS 10.3 on it). web-animations.min.js is under 50k and falls back to using native calls when the browser supports them.

Has anybody used this, or a similar "external" js files in a BGA project? I've put the file into my "modules" directory, but I'm not sure how to reference it to get it to load at the right time. The documentation assumes you have control of the whole page's html, and just suggests putting this somewhere near the top:

Code: Select all

<!-- Include the polyfill -->
<script src="web-animations.min.js"></script>
but obviously this isn't possible to game developers, at least not directly. Any tips?

Re: Anybody used web-animations polyfill?

Posted: 27 January 2021, 22:41
by Tisaac
I am using some external libs in my projects. You can either load them in your tpl file by using the GAMEURL variable to have the correct URL, or you load them using dojo if you need them in your js (eg I'm loading Hammerjs for Santorini in my js directly).

Re: Anybody used web-animations polyfill?

Posted: 28 January 2021, 13:08
by shadowphiar
Thanks, yes using the .tpl works (though I had to use "{GAMETHEMEURL}" for the substitution).