New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sticky-ad IOS scrolling issue fix #3700
Conversation
@@ -28,6 +28,7 @@ amp-sticky-ad { | |||
} | |||
|
|||
.-amp-sticky-ad-layout { | |||
visibility: hidden; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can we prevent this from being customized?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!important
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That also prevent myself from setting it to visible
.
Here's my solution:
this.element.classList.add('-amp-sticky-ad-display')
.-amp-sticky-ad-display { visibility: visible !important; }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have to set visible !important
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll have to set it to visible
via a class as well. E.g.
.myclass {
visibility: hidden !important;
}
.myclass.visible {
visibility: visible !important;
}
@zhouyx Could you please explain why the issue is happening now? What causes the blink on iOS? |
Demo please. This worked perfectly for me before. |
That probably needs one to scroll really fast. |
Got it. The demo I was playing with earlier was not the current version of |
I don't remember putting |
Sadly I still haven't found the reason to the blink. Still looking for it, but it makes me really hard to debug because the issue only occurs when fetching |
@zhouyx To confirm, however, according to the description of this PR it follows that switching from |
Yes, switching from |
Discuss with @mkhatib, find one thing. Note to self. |
PTAL |
@@ -160,7 +159,7 @@ | |||
</div> | |||
</header> | |||
<main role="main"> | |||
<amp-sticky-ad layout="nodisplay"> | |||
<amp-sticky-ad layout="container"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to specify layout=container
- it's default. However, there's an issue here and why I'd like to go back to nodisplay
. To start with, it does as as nodisplay
. The second reason is that by the time the amp-sticky-ad
code is done downloading the element might be actually visible, which could trigger all kind of issues that we don't want. Instead, we need to start with nodisplay
, but as soon as amp-sticky-ad
is initialized (buildCallback
) to remove display:none
and instead set visibility:hidden
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean that before we get amp-sticky-ad
css file, it might be treated as a normal div and would be visible.
changed the layout type back to nodisplay
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The blink comes back with display
change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I see the updated code? The goal is to remove display:none
and set visibility:hidden
as soon as possible, e.g. in the buildCallback
. I can't imagine the blink will still be there in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current code is updated. Here's what I found, after setting display:flex
through css classList, I still find style = "display: none"
on the HTML element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I add toggle(this.element, true)
to buildCallback()
, unfortunately I still see blink
@@ -38,21 +39,25 @@ class AmpStickyAd extends AMP.BaseElement { | |||
dev.warn(TAG, `TAG ${TAG} disabled`); | |||
return; | |||
} | |||
|
|||
toggle(this.element, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably should be done after the class is set below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed because the NODISPLAY
layout? Why don't we change it to CONTAINER
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get this comment from @dvoytenko
No need to specify layout=container - it's default. However, there's an issue here and why I'd like to go back to nodisplay. To start with, it does as as nodisplay. The second reason is that by the time the amp-sticky-ad code is done downloading the element might be actually visible, which could trigger all kind of issues that we don't want. Instead, we need to start with nodisplay, but as soon as amp-sticky-ad is initialized (buildCallback) to remove display:none and instead set visibility:hidden.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@zhouyx The code looks fine now. At this point, since we remove
If both (1) and (2) help - my preference is (2). |
@@ -29,17 +29,21 @@ amp-sticky-ad { | |||
|
|||
.-amp-sticky-ad-layout { | |||
display: flex; | |||
visibility: hidden; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't we forcing this with !important
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right, will fix
PTAL |
LGTM. |
fix the issue that
amp-sticky-ad
disappear before it showsamp-ad
.But ad still only displays after scrolling is fully stopped.
#3599