【问题标题】:polymer core-animated-pages transition聚合物核心动画页面过渡
【发布时间】:2014-07-10 09:02:19
【问题描述】:

我试图理解核心动画页面,但我不明白我失败的地方。我已经实现了http://www.polymer-project.org/docs/elements/core-elements.html#core-animated-pages中第一个演示的两个演示示例

但是过渡不起作用!哪个是问题??这是代码

        <!doctype html>
        <html>
        <head>

        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">

      <script src="components/platform/platform.js"></script>
      <link href="components/core-animated-pages/core-animated-pages.html" rel="import">
      <link href="components/core-animated-pages/transitions/cross-fade.html" rel="import">
      <link href="components/core-animated-pages/transitions/slide-from-right.html" rel="import">
      <link href="components/core-animated-pages/transitions/hero-transition.html" rel="import">

      <style>
      #hero1 {
        position: absolute;
        top: 0;
        left: 0;
        width: 300px;
        height: 300px;
        background-color: orange;
      }
      #hero2 {
        position: absolute;
        top: 200px;
        left: 300px;
        width: 300px;
        height: 300px;
        background-color: orange;
      }
      #bottom1, #bottom2 {
        position: absolute;
        bottom: 0;
        top: 0;
        left: 0;
        height: 50px;
      }
      #bottom1 {
        background-color: blue;
      }
      #bottom2 {
        background-color: green;
      }
    </style>
    <!-- // hero-transition and cross-fade are declared elsewhere -->
        <core-animated-pages transitions="hero-transition cross-fade">
          <section id="page1">
            <div id="hero1" hero-id="hero" hero></div>
            <div id="bottom1" cross-fade></div>
          </section>
          <section id="page2">
            <div id="hero2" hero-id="hero" hero></div>
            <div id="bottom2" cross-fade></div>
          </section>
        </core-animated-pages>

      <script>
        document.addEventListener('click', function(e) {
        var pages = document.querySelector('core-animated-pages');
        pages.selected = (pages.selected + 1) % pages.children.length;
      });
      </script>
    </body>
    </html>

谢谢

【问题讨论】:

    标签: polymer material-design


    【解决方案1】:

    您是否将 Polymer/core-style 模块添加到您的项目中?没有它我会得到一个 Uncaught ReferenceError: CoreStyle is not defined 并且不会渲染任何过渡动画。

    【讨论】:

    • 是的,它有效。我正在使用 Polymer 0.3.3 并使用 Chrome 37 和 Firefox 30 对其进行了测试。
    【解决方案2】:

    你只是忘了把尺寸放在核心页面动画转换中,在你的 CSS 中实现这个代码

    core-pages-animated transitions {
        width: 100%; 
        height: 100%;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-11
      • 1970-01-01
      相关资源
      最近更新 更多