我的聚合物应用程序将对象的top从任意位置动画到0。它现在正在使用速度来完成这个任务,因为从任何当前状态到一个新状态的动画方式是非常明显的。聚合物的core-animation是否有可能(甚至是适当的)?所有演示都显示每个关键帧的固定值。
发布于 2015-01-10 06:36:03
我知道的一种方法是使用核心动画的customEffect回调。
当单击此按钮时,此示例将显示该按钮:
<script src="http://www.polymer-project.org/components/webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="http://www.polymer-project.org/components/polymer/polymer.html">
<link rel="import" href="http://www.polymer-project.org/components/core-animation/core-animation.html">
<polymer-element name="test-element">
<template>
<core-animation id="animation" duration="1000" easing="ease-in-out" fill="forwards"></core-animation>
<div relative>
<button on-tap="{{go}}" style="position: absolute;">Click me</button>
</div>
</template>
<script>
Polymer({
go: function(e, detail, sender) {
var maxTop = 100;
// animation target
this.$.animation.target = sender;
// custom animation callback
this.$.animation.customEffect = function(timeFraction, target, animation) {
target.style.top = (maxTop * timeFraction) + "px";
};
// being the animation
this.$.animation.play();
}
});
</script>
</polymer-element>
<test-element></test-element>
https://stackoverflow.com/questions/27871931
复制相似问题