top
我的 Polymer 应用程序将对象从任意位置动画化到0
. 它现在正在使用 Velocity 来执行此操作,因为从任何当前状态动画到新状态的方式非常明显。与 Polymer's 有可能(甚至是适当的)core-animation
吗?所有演示都在每个关键帧处显示固定值。
问问题
372 次
1 回答
1
我知道的一种方法是使用核心动画的 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>
于 2015-01-10T06:36:03.590 回答