Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent <amp-sidebar> from going back to the top of the page

Tags:

amp-html

I'm trying to create a simple replacement for my previous hamburger menu, which had some navigation links that would simply scroll pageview to a specified section using href="#section".

Since I cannot use Checkbox trick anymore, I had to use <amp-sidebar> for it:

<amp-sidebar id="sidebar" layout="nodisplay" side="right">
    <ul>
        <li>
            <a href="#secion1">Section 1</a>
        </li>
        <li>
            <a href="#secion2">Section 2</a>
        </li>
        <li>
            <a href="#secion3">Section 3</a>
        </li>
    </ul>
</amp-sidebar>

The problem is, that every time the sidebar is closed, the page gets scrolled back to it's top position (even the URL is reverted to the original state, so the #section is removed).

Is there any way to prevent this behavior?

like image 715
mdziekon Avatar asked Jul 19 '16 13:07

mdziekon


1 Answers

That behaviour seems like a bug. Please file an issue on the Github project: https://github.com/ampproject/amphtml/issues/new

like image 192
ade Avatar answered Oct 18 '22 23:10

ade