Google AMP:可以在滚动条上隐藏 header 吗?

Google AMP: Hide header on scroll possible?

Google-AMP 工作人员需要帮助。 我试图在向下滚动时隐藏导航栏。如果在向上滚动时再次显示它。 我想隐藏 header

<nav id="navToHide">Nvabar</nav>

AMP 动画代码我的截图:

<amp-animation id="hideNav" layout="nodisplay">
    <script type="application/json">
        {
        "duration": "200ms",
        "fill": "forwards",
        "iterations": "1",
        "direction": "alternate",
        "animations": [{
            "selector": "#navToHide",
            "keyframes": [{
                "transform": "translateY(-180px)"
            }]
        }]
        }
    </script>
</amp-animation>

AMP 位置观测器代码:

<amp-position-observer on="enter:select-item1.start" layout="nodisplay"></amp-position-observer>

我想在滚动时制作类似于导航栏隐藏的东西。 就像下面这个例子。 https://www.w3schools.com/howto/howto_js_navbar_hide_scroll.asp

我正在努力避免javascript

有一种非常简单的方法可以使用 amp-fx-collection's float-in 属性来执行此操作。

将所需的<amp-fx-collection>脚本添加到页面的头部:

<script async custom-element="amp-fx-collection" src="https://cdn.ampproject.org/v0/amp-fx-collection-0.1.js"></script>

并将 amp-fx='float-in-top' 属性应用到您的 <nav> 元素。

您可以在这个视频中看到它的演示:

AMP Conf 2019, amp.dev live!