How to add a side-navigation in polymer

心不动则不痛 提交于 2019-12-11 20:08:17

问题


I want to add a side navigation like this to my side:

https://www.google.com/design/spec/material-design/introduction.html

There should be a menu button and a sidenav opens:

But i cant find this method in polymer. The only possibility is the paper-drawer-panel but this is opend all the time...

My working paper-drawer-panel example: https://www.sese7.de/polymer/


Does anybody has an idea how to do this with polymer or maybe with https://customelements.io/

Thanks in advance ;)


回答1:


Try setting the forceNarrow attribute to true.

Below is the documentation from the paper-drawer-panel api docs: https://elements.polymer-project.org/elements/paper-drawer-panel

forceNarrow

Boolean

default: false

If true, ignore responsiveWidth setting and force the narrow layout.




回答2:


Paper-drawer-panel has a closeDrawer()-method.

A short example here:

var drawerPanel = Polymer.dom(document).querySelector('#paperDrawerPanel');

if (drawerPanel.narrow) {
    drawerPanel.closeDrawer();
}

The example is from "Polymer Starter Kit".



来源:https://stackoverflow.com/questions/33463507/how-to-add-a-side-navigation-in-polymer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!