1
amp-position-observerを使用してAMP状態を設定することはできますか?Amp-html - amp-position-observerを使用してamp-bindで使用されるAMP.setState()を呼び出すことはできますか?
私は成功せず、次のコードを試してみました:
<!doctype html>
<html ⚡>
<head>
<script async="" src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
<script custom-element="amp-position-observer" src="https://cdn.ampproject.org/v0/amp-position-observer-0.1.js" async></script>
</head>
<body>
<p [text]="'Hello ' + foo">Hello World</p>
<div class="spacer"></div>
<amp-position-observer
intersection-ratios="0"
on="enter:AMP.setState({foo: 'amp-bind'})"
layout="nodisplay">
</amp-position-observer>
</body>
</html>
採用されている解決策は、関連GitHubスレッドで説明されています。https://github.com/ampproject/amphtml/issues/11735 – Gab