Core-toggle-drawer into an other custom element

77 views
Skip to first unread message

Sébastien MARCELLIN

unread,
Apr 5, 2015, 2:24:50 PM4/5/15
to polym...@googlegroups.com

i'm trying scaffold an interface with a app-element who implement the core-drawer. Into the main drawer-div, i have some custom elements and i want to give us the capability to display or hide the drawer panel.

By example, my main app element should be :

<core-drawer-panel> <div drawer> ... </div> <div main> <other-custom-element></other-custom-element> </div> </core-drawer-panel>

And my custom element :

<polymer-element name="custome-element"> ... <div core-drawer-toggle>clic me to open the drawer parent !</div> ... </polymer-element>

Of course, that doesn't work because core-drawer-toggle don't know is parent.... So, how can i do that ?


Thanks !

Rob Dodson

unread,
Apr 9, 2015, 3:47:14 PM4/9/15
to Sébastien MARCELLIN, polymer-dev
Rather than use core-drawer-toggle, I would recommend you manually call the toggle method of the core-drawer-panel element whenever that div inside of your custom-element is clicked. I may go about this by listening for click, or a custom event coming from custom-element, in some common parent (whatever is holding the core-drawer-panel). When the parent hears that event, it calls toggle on core-drawer-panel.

Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/b86e5fa9-6242-45b5-9ad8-8412777414b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

andr...@gmail.com

unread,
May 6, 2015, 6:25:18 AM5/6/15
to polym...@googlegroups.com, marce...@gmail.com
Perhaps the easy way to do this, correct me if I'm wrong, is to give the core-drawer-panel an id (mainmenu for example),
Then on the button you want to open the menu have onclick="document.getElementById('mainmenu').setAttribute('selected','drawer');"
Of course this means you can't use the same button to hide the menu again (you could modify the onclick to include an if) but most people have their menus cover their buttons anyway.

Eric Eslinger

unread,
May 6, 2015, 7:24:29 AM5/6/15
to andr...@gmail.com, polym...@googlegroups.com, marce...@gmail.com
Yeah, I had problems with some corner cases of core-drawer-panel, and they all were solved by just manually toggling the panel (finding the element and calling toggle()) rather than using the prefab button.

Reply all
Reply to author
Forward
0 new messages