首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用聚合物核心动画从当前值动画

用聚合物核心动画从当前值动画
EN

Stack Overflow用户
提问于 2015-01-10 01:34:01
回答 1查看 372关注 0票数 0

我的聚合物应用程序将对象的top从任意位置动画到0。它现在正在使用速度来完成这个任务,因为从任何当前状态到一个新状态的动画方式是非常明显的。聚合物的core-animation是否有可能(甚至是适当的)?所有演示都显示每个关键帧的固定值。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-01-10 06:36:03

我知道的一种方法是使用核心动画的customEffect回调。

当单击此按钮时,此示例将显示该按钮:

代码语言:javascript
复制
<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>

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27871931

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档