2017-10-18 3 views
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> 
+0

채택 된 솔루션은 관련 GitHub 스레드에 설명되어 있습니다. https://github.com/ampproject/amphtml/issues/11735 – Gab

답변

2

그것은 설계 할 수 없습니다. setState은 강력한 (높은 신뢰도) 동작이며 직접적인 사용자 상호 작용만으로 트리거 할 수 있습니다. 스크롤은 강력한 사용자 상호 작용 신호로 간주되지 않습니다. 현재 position-observer는 앰프 애니메이션이나 비디오 재생 또는 검색과 같이 신뢰도가 낮은 액션을 트리거 할 수 있습니다.

관련 문제