I have added a question on stackoverflow.com about that:
https://stackoverflow.com/questions/46813702/amp-html-can-i-use-amp-position-observer-to-call-amp-setstate-used-in-amp-bi
It looks like that amp-position-observer is not able to call AMP.setState().
Hi @geberele
Replied on Stackoveflow, pasting here as well:
"It is not possible by design. setState is a powerful (high-trust) action and only triggerable by direct user interaction. Scrolling is not considered a strong user interaction signal. Currently position-observer can only trigger low-trust actions such as playing or seeking amp-animation or videos."
Allowing scrolling to trigger setState is not likely something we support as it opens up opportunities for bad UX that AMP has been trying to protect agains.
What is the use-case you have in mind? Maybe there are work-around or something we can provide via a different component.
/cc @ericlindley-g
Hi @aghassemi,
Thanks for your reply.
We want to have a sticky banner on top of the page that stops to be sticky when finds another banner in the page.
Is that feasible with AMP?
Many thanks for the support.
@geberele Something like this: http://html5-demos.appspot.com/static/css/sticky.html ?
If so, standard position: sticky is meant for exactly this sort of cases. Browser support for it has grown a lot recently and all newest versions of browsers support it.
@aghassemi that is the perfect solution, thank you!
It looks like that AMP doesn't like the property 'position: sticky;' in the CSS if in the element there is a banner, the error message in the log console is:
"
(https://github.com/ampproject/amphtml/issues/2238)
@geberele this restriction is on amp-ad and not every element and is by design ( we don't want sticky or fixed position ads on AMP pages), are you seeing otherwise?
@aghassemi I was trying to achieve exactly that in AMP, a sticky banner on top of the page that stops to be sticky when finds another banner in the page.
Thanks for your help.
closing as by design (ads not allowed in fixed position elements)
HI,
I need to open amp-lightbox once user scroll down or I need to open amp-light box after some interval in page.
And this page's amp-lightbox popup have one form.
My purpose is once user visit some specific page that time need to open amp-lightbox with one form and user need to fill required details then user can move next in page.
I am trying to find solution but not able to figure out with best way.
Any one have any idea how I can achieve this?
In Advance thank you for your help.
Thank you
@aghassemi , Sir do you have any idea on my point?
Thank you
Most helpful comment
Hi @geberele
Replied on Stackoveflow, pasting here as well:
"It is not possible by design.
setStateis a powerful (high-trust) action and only triggerable by direct user interaction. Scrolling is not considered a strong user interaction signal. Currently position-observer can only trigger low-trust actions such as playing or seeking amp-animation or videos."Allowing scrolling to trigger
setStateis not likely something we support as it opens up opportunities for bad UX that AMP has been trying to protect agains.What is the use-case you have in mind? Maybe there are work-around or something we can provide via a different component.
/cc @ericlindley-g