Skip to content
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

Optional overlay #7

Merged
merged 2 commits into from
Apr 21, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 36 additions & 16 deletions paper-fab-menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
@homepage http://cwdoh.github.io/paper-fab-menu
-->

<polymer-element name="paper-fab-menu" attributes="icon closeIcon duration zIndex">
<polymer-element name="paper-fab-menu" attributes="icon closeIcon duration zIndex overlay">
<template>
<link rel="stylesheet" href="paper-fab-menu.css">
<style>
Expand Down Expand Up @@ -62,7 +62,9 @@
</style>
</template>

<core-overlay id="overlay" layered backdrop transition="core-transition-fade" on-core-overlay-open="{{overlayOpenedChanged}}"></core-overlay>
<template if="{{overlay}}">
<core-overlay id="overlay" layered backdrop transition="core-transition-fade" on-core-overlay-open="{{overlayOpenedChanged}}"></core-overlay>
</template>
<div layout vertical center class="container" id="fam">
<content id="content" select="paper-fab-menu-item"></content>
<paper-fab icon="menu" id="trigger" on-click="{{toggle}}"></paper-fab>
Expand Down Expand Up @@ -125,6 +127,14 @@
* @default 10000
*/
zIndex: 10000,

/**
* Set if the overlay of screen should be used when the menu is opened.
* @attribute overlay
* @type boolean
* @default false
*/
overlay: false,

ready: function() {
this.calculateTransitionEffects.apply(this);
Expand All @@ -134,7 +144,9 @@
},

overlayOpenedChanged: function() {
this.opened = this.$.overlay.opened;
if(this.overlay){
this.opened = this.$.overlay.opened;
}
},

/**
Expand All @@ -157,16 +169,20 @@
return;

for (l in backdrops) {
if (backdrops[l] != this.$.overlay.scrim) {
// add core-opened to other backdrop for workaround
backdrops[l].classList.add('core-opened')

// remove overlay of fab-menu.
this.$.overlay.scrim.remove();

// just do this at first backdrop.
return;
}
if(this.overlay) {
if (backdrops[l] != this.$.overlay.scrim) {
// add core-opened to other backdrop for workaround
backdrops[l].classList.add('core-opened')

// remove overlay of fab-menu.

this.$.overlay.scrim.remove();


// just do this at first backdrop.
return;
}
}
}
}

Expand All @@ -190,8 +206,10 @@
this.opened = true;
this.$.trigger.icon = this.closeIcon;
this.$.trigger.setAttribute("activate", "");

this.$.overlay.open();

if(this.overlay){
this.$.overlay.open();
}
},

/**
Expand All @@ -204,7 +222,9 @@
this.$.trigger.icon = this.icon;
this.$.trigger.removeAttribute("activate");

this.$.overlay.close();
if(this.overlay){
this.$.overlay.close();
}
},

update: function() {
Expand Down