neon-animation icon indicating copy to clipboard operation
neon-animation copied to clipboard

[neon-animatable-behavior.html] - Issue with getAnimationConfig

Open bsnuggs1 opened this issue 10 years ago • 2 comments

Inside _runAnimationEffects I am having an issue where anytime I animate my polymer object I get a console warning saying:

action-buttons-menu:  not found!

After doing some debugging, I traced the source to getAnimationConfig in neon-animatable-behaviour.html where it is running the following code at line 148.

getAnimationConfig: function(type) {
      var map = [];
      var allConfigs = [];
      this._getAnimationConfigRecursive(type, map, allConfigs);
      // append the configurations saved in the map to the array
      for (var key in map) {
          allConfigs.push(map[key]);
      }
      return allConfigs;
}

Normally this would run fine. However, I have a simple function on the Array object to give me an easy conditional when searching arrays.

Array.prototype.contains = function (item) {
    return this.indexOf(item) !== -1;
};

When getAnimationConfig iterates through the map, it finds the contains function and believes it to be an animation config that needs to be used later in _runAnimationEffects.

Should I remove the function I added to Array?

bsnuggs1 avatar Nov 10 '15 19:11 bsnuggs1

Actually, when looking a little closer, it seems that there is a minor typo. In getAnimationConfig, why is our map an array, when _getAnimationConfigRecursive adds each item as a key, which would imply the map is a generic Object (neon-animatable-behavior line 127)?

If line 144 in neon-animatable-behavior is replaced with:

var map = {};

This should resolve the issue.

bsnuggs1 avatar Nov 12 '15 14:11 bsnuggs1

Thanks for reporting, I will take a look.

cdata avatar Dec 10 '15 22:12 cdata