adobe-webplatform / Snap.svg

The JavaScript library for modern SVG graphics.
http://snapsvg.io
Apache License 2.0
13.96k stars 1.15k forks source link

Cannot assing attr fill when hover on element #595

Open benydc opened 6 years ago

benydc commented 6 years ago

I'm getting an error when trying to add fill on animate, it works fine with fillOpacity.

TypeError: eq is undefined[Learn More] snap.svg.js:3686:17
elproto.animate

And the code:

seat24.hover(() => { seat24.animate({ fill: "#808080" }, 200, mina.easeinout); }, () => { seat24.animate({ fill: "#FFFFFF" }, 200, mina.easeinout); });

And the error happens here in snap.svg:

elproto.animate = function (attrs, ms, easing, callback) {
        if (typeof easing == "function" && !easing.length) {
            callback = easing;
            easing = mina.linear;
        }
        if (attrs instanceof Animation) {
            callback = attrs.callback;
            easing = attrs.easing;
            ms = attrs.dur;
            attrs = attrs.attr;
        }
        var fkeys = [], tkeys = [], keys = {}, from, to, f, eq,
            el = this;
        for (var key in attrs) if (attrs[has](key)) {
            if (el.equal) {
                eq = el.equal(key, Str(attrs[key]));
                from = eq.from;
                to = eq.to;
                f = eq.f;
            } else {
                from = +el.attr(key);
                to = +attrs[key];
            }
            var len = is(from, "array") ? from.length : 1;
            keys[key] = slice(fkeys.length, fkeys.length + len, f);
            fkeys = fkeys.concat(from);
            tkeys = tkeys.concat(to);
        }
ibrierley commented 6 years ago

Have you tried it with the dev branch 0.5.2 ?

benydc commented 6 years ago

@ibrierley nope, I will try with that.

benydc commented 6 years ago

@ibrierley that worked! can I use dev 0.5.2 on production?