问题
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