Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 聚合物霓虹灯动画多重完成侦听器_Javascript_Polymer_Polymer 1.0 - Fatal编程技术网

Javascript 聚合物霓虹灯动画多重完成侦听器

Javascript 聚合物霓虹灯动画多重完成侦听器,javascript,polymer,polymer-1.0,Javascript,Polymer,Polymer 1.0,我正在编写一个实现元素库的聚合元素。我正在为我的元素实现NeonAnimationRunnerBehavior行为。该元素尤其具有多个动画(运行良好),在每个动画结束时需要调用唯一的结束函数 文档建议使用如下侦听器: listeners: { // this event is fired when the animation finishes "neon-animation-finish": "imageFadeOutComplete" }, animateFadeIn: fu

我正在编写一个实现元素库的聚合元素。我正在为我的元素实现
NeonAnimationRunnerBehavior
行为。该元素尤其具有多个动画(运行良好),在每个动画结束时需要调用唯一的结束函数

文档建议使用如下侦听器:

listeners: {
    // this event is fired when the animation finishes
    "neon-animation-finish": "imageFadeOutComplete"
},
animateFadeIn: function() {
  this.playAnimation('imageFadeIn', 'imageFadeIn');
},

animateFadeOut: function() {
  this.playAnimation('imageFadeOut', 'imageFadeOut');
},

_animationFinish: function(e, animation) {
  switch(animation) {
    case 'imageFadeOut':
      ...
      break;
    case 'imageFadeIn':
      ...
      break;
  }
}
如果有一个动画回调,这将非常有用。但我有一个用于悬停、离开悬停状态和单击(点击)我的元素的动画。我尝试过探索
霓虹灯动画完成
事件,但似乎每个动画都是相同的

所以,我的问题是:是否有可能让每个动画在完成时调用不同的函数

我希望是这样的:

....

animationConfig: {
    value: function() {
        return {
            "imageFadeOut": {
                name: "fade-out-animation",
                node: this.$.image,
                complete: "imageFadeOutComplete"
            },
...

但是,这不起作用。

playAnimation
接受第二个参数,该参数将作为细节传递给
neon animation finish
事件处理程序,因此您可以执行以下操作:

listeners: {
    // this event is fired when the animation finishes
    "neon-animation-finish": "imageFadeOutComplete"
},
animateFadeIn: function() {
  this.playAnimation('imageFadeIn', 'imageFadeIn');
},

animateFadeOut: function() {
  this.playAnimation('imageFadeOut', 'imageFadeOut');
},

_animationFinish: function(e, animation) {
  switch(animation) {
    case 'imageFadeOut':
      ...
      break;
    case 'imageFadeIn':
      ...
      break;
  }
}

我看到它需要两个参数,但不确定如何实现它。第二个参数可以是任何类型。我正在传递事件处理程序随后调用的函数。