amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

Sidebar is AutoScrolling Page when Toggled

Open rbp15 opened this issue 10 years ago • 27 comments

When applying a top margin to the amp-sidebar list in order to preserver our head branding and links we noticed upon toggling the sidebar to the active state that the page is scrolling down thereby cutting off part of our header, brand and links.

Please see video here: http://www.screencast.com/t/7FeIuFBim6z

Desired behavior is that toggle state does nothing but show and hide sidebar without page movement. Taking off the margin I added to the menu list again, makes it to where the menu hides the branding and other options available to the user in the header.

This is happening in the mobile simulator and phone devices.

Thank you, -R @cramforce @jmadler

rbp15 avatar Nov 29 '16 21:11 rbp15

/to @ericlindley-g

rudygalfi avatar Nov 30 '16 19:11 rudygalfi

You're likely not updating the height style, then. Since you've added some X pixels to the margin-top, and the default height is 100vh, you need to subtract the margin-top from that:

sidebar {
  margin-top: 200px;
  height: calc(100vh - 200px);
}

jridgewell avatar Nov 30 '16 19:11 jridgewell

@randallbpotter15 If the fix @jridgewell suggests doesn't work, you can send over a link and we can take a look to determine if it's an AMP bug or implementation bug. Thanks!

ericlindley-g avatar Dec 01 '16 02:12 ericlindley-g

@ericlindley-g and @jridgewell : The fix didn't work in this case. It moved the nav menu further down within it's context of the sidebar. I've uploaded a video with the safari simulator debug combo to illustrate the styles and behavior with the proposed fix. I'll see if I can get this on an environment you all can access. Let me know if you see something in the video though.

Edit: 12/01/2016: 9:11AM EST: Better video: http://www.screencast.com/t/7AwJKWdO9z

Thank you, -Randall

rbp15 avatar Dec 01 '16 14:12 rbp15

You're putting the height on the wrong element. From your screencast, you've put it on <ul>, but that won't affect the sidebar itself.

You have a .nav-menu class on the <amp-sidebar> with:

.nav-menu {
  padding: 15px 0px 1px 10px;
  margin-top: 25px;
}

You need to add a height style to that class to fix.

jridgewell avatar Dec 01 '16 18:12 jridgewell

That worked - thank you!

rbp15 avatar Dec 01 '16 18:12 rbp15

Reared it's head again once in the prod carousel. http://www.screencast.com/t/AccW0XhdynH3

can replicate by googling "cnn" on mobile.

is there a way to simulate this prod carousel so we can catch these things before prod?

rbp15 avatar Dec 09 '16 17:12 rbp15

@randallbpotter15 Yes, you can opt into "Dev Channel" here https://cdn.ampproject.org/experiments.html to get all changes one week early.

cramforce avatar Dec 09 '16 17:12 cramforce

Thanks @cramforce - does that apply to the actual amp search carousel viewer? In the screencast above the top amp bar with the bullets that lets you move from result to result?

One of my goals here is to be able to view what my page will look like in that container before I release to prod. (besides getting a prod ready fix)

Has this code in it: <g-fixed-header id="amp-hdr" class="_Gog fp-w _vmh _tlo"><div class="_fpg"><span class="_hpg _Ewo _wtf _Dtf" role="button" tabindex="0" jsaction="ampfp.cl" aria-label="close" data-ved="0ahUKEwi30Ma2xefQAhWBMyYKHZkNBhcQ8owBCAI"><svg focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"></path></svg></span><span class="_gpg amp-ttlctr amp-wibbl" role="heading"><span class="amp-ttltxt">amp.cnn.com</span>

rbp15 avatar Dec 09 '16 18:12 rbp15

+1 for a search carousel simulator we can drop pages into - that would be really nice.

jpettitt avatar Dec 09 '16 18:12 jpettitt

Also for reference here is the same code in our pre-prod environment - working with the original fix from this ticket. http://www.screencast.com/t/Ay4a5nm03e

rbp15 avatar Dec 09 '16 18:12 rbp15

I can bring up such a demo viewer. It unfortunately comes with a significant security dimension, making it not all that easy.

cramforce avatar Dec 09 '16 21:12 cramforce

@cramforce I'm down with it even if it has large security.

rbp15 avatar Dec 09 '16 21:12 rbp15

Reopening and passing to @camelburrito for the regression (specifically in the prod viewer)

ericlindley-g avatar Jan 05 '17 16:01 ericlindley-g

Thank you @ericlindley-g :) I'm still seeing interplay between the carousel's injected header and the top of the actual page content. Scrolling doesn't seem to be happening - but it's hard to tell what to adjust top distances based on how the carousel is injected and can change. (hence the ask for the test harness up above)

rbp15 avatar Jan 05 '17 16:01 rbp15

I think there are multiple things being discussed here. Can someone clarify what is the fix we are looking for here.

camelburrito avatar Jan 05 '17 22:01 camelburrito

BTW figured out how to force a viewer - http://www.google.com/amp/<amp article domain>/<amp article path> does the trick, but only on mobile or in mobile emulation. Not sure if this is a bug or a feature but I like it.

Ex https://www.google.com/amp/dailydot.relaymedia.com/amp/entertainment/only-in-hella-webseries-interview

jpettitt avatar Jan 06 '17 04:01 jpettitt

BTW figured out how to force a viewer -http://www.google.com/amp//

Yup, that'll get you into a viewer context. It's a little different than what happens on a normal search, though, since there's no left/right swipe to next article.

but only on mobile or in mobile emulation. Not sure if this is a bug or a feature but I like it.

The forwarding is on purpose for shares that end up being clicked on Desktop.

jridgewell avatar Jan 06 '17 18:01 jridgewell

@jridgewell By "a little different" - does that mean it's code is different or just that it's a single view and not a true swiping carousel?

@cramforce Were there any more thoughts around a demo viewer? Or could you elaborate on the security dimension you mentioned?

@camelburrito Did you get the information you needed for regression?

rbp15 avatar Jan 12 '17 05:01 rbp15

@randallbpotter15 "Sidebar is AutoScrolling Page when Toggled " --> is this the issue you are seeing?

camelburrito avatar Jan 12 '17 05:01 camelburrito