rubenspgcavalcante / leaflet-ant-path

🌿🐜 Creates a leaflet polyline with a 'ant-path' animated flux
http://rubenspgcavalcante.github.io/leaflet-ant-path
MIT License
463 stars 80 forks source link

Builds with rollup "don't crawl" #132

Closed devleaks closed 4 years ago

devleaks commented 4 years ago

Type:

Environment:

I'm going to open a PR:

Description: When I assemble a simple es6 script with rollup, ants don't craw! The display of the polyline remains static. Tried to resume() but no progress. Any idea?

Please clone this repo as a test case.

I don't know webpack. I'd be curious to see if a webpack build works. This may be a rollup issue.

Thanks for your help.

devleaks commented 4 years ago

Don't ask me why, but I noticed that <svg class="leaflet-ant-path"...> is missing an animation-duration attribute... If I add it (in the browser inspector), it crawls. :-) But why doesn't it get written when bundling with rollup?

devleaks commented 4 years ago

I tracked this one down. After I noticed some missing styles, I found the function that does attach them (_calculateAnimationSpeed). I looked at the generated code and found that for some obscure buggy reason, rollup strips the following piece of code from _calculateAnimationSpeed():

a = ["-webkit-", "-moz-", "-ms-", "-o-", ""]
    .map(function(t) {
        return "".concat(t, "animation-duration: ").concat(i);
    })
    .join(";");
Array.from(o, function(t) {
    (t.style.cssText = a), t.setAttribute("data-animated", "true");
});

If I add this piece of code in the rollup generated file, it works.