How to trigger Polymer paper ripple animation by API code?

懵懂的女人 提交于 2019-12-24 17:42:51

问题


I tried $.find("paper-ripple").animate(); described at https://elements.polymer-project.org/elements/paper-ripple but this does not work.


回答1:


You can use simulatedRipple() method of paper-ripple.

<!DOCTYPE html>
<html>
<head>
  <base href="https://polygit.org">
  <script src="/components/webcomponentsjs/webcomponents-lite.min.js"></script>
  <link rel="import" href="/components/polymer/polymer.html">
  <link rel="import" href="/components/paper-ripple/paper-ripple.html">
  <style>
    .card {
      position: relative;
      display: inline-block;
      width: 300px;
      height: 240px;
      vertical-align: top;
      background-color: #fff;
      box-shadow: 0 12px 15px 0 rgba(0, 0, 0, 0.24);
    }
  </style>
</head>
<body>      
  <template id="demo" is="dom-bind">
    <div class="card">
      <paper-ripple recenters></paper-ripple>
    </div>
  </template>
</body>


<script>
  var demo = document.querySelector('#demo');  

  demo.addEventListener('dom-change', function() {
    setInterval(triggerRipple, 1000);
  });
  
  triggerRipple = function() {
    var paperRipple = document.querySelector('paper-ripple');
    paperRipple.simulatedRipple();
  }
</script>
</html>


来源:https://stackoverflow.com/questions/32277017/how-to-trigger-polymer-paper-ripple-animation-by-api-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!