Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
polymer-overlay: refactor (no animations yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yvonne Yip committed Jul 9, 2013
1 parent 1297a41 commit a385ebf
Show file tree
Hide file tree
Showing 3 changed files with 171 additions and 74 deletions.
40 changes: 28 additions & 12 deletions polymer-overlay/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link rel="import" href="polymer-overlay.html">
<script src="../../polymer/polymer.js"></script>
<style>
polymer-overlay {
.dialog {
box-sizing: border-box;
-moz-box-sizing: border-box;
font-family: Arial, Helvetica, sans-serif;
Expand Down Expand Up @@ -49,35 +49,51 @@
<label>scrim: <input type="checkbox" onchange="scrimChange(event)"></label>
)
<br>
<polymer-overlay id="dialog" class="polymer-overlay-scale-slideup">
<div id="dialog" class="dialog polymer-overlay-scale-slideup">
<polymer-overlay></polymer-overlay>
<h2>Dialog</h2>
<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed fringilla sapien sed enim sollicitudin laoreet. Suspendisse suscipit, metus ac volutpat sodales, libero magna semper lacus, molestie fringilla massa orci ut arcu. Nullam sodales urna sit amet odio vehicula mattis.</div><br><br>
<div>Ut aliquam vulputate congue. Vestibulum pretium pretium nulla quis sollicitudin. Praesent lacinia congue erat nec mattis. Fusce commodo lacus est. Duis turpis eros, ultrices sed aliquet non, blandit egestas velit. Integer a augue nec lorem tristique hendrerit. Curabitur imperdiet risus id enim bibendum vestibulum. Integer id magna at arcu faucibus fermentum vel a augue. Sed fringilla venenatis dolor, in blandit magna molestie luctus. Vestibulum dignissim posuere ultrices. Aenean urna nisl, tincidunt vitae iaculis ut, pharetra nec eros.</div><br><br>
<div>
<input placeholder="say something..." autofocus oninput="somethingCheck()"></input><br>
I agree with this wholeheartedly.
<polymer-overlay id="confirmation">
<div id="confirmation" class="dialog">
<polymer-overlay></polymer-overlay>
Thank you.
</polymer-overlay>
</div>
</div><br><br>
<button overlay-toggle>OK</button>
</polymer-overlay>
</div>

<br><br>

<button overlay="#dialog2">Toggle Dialog 2</button>

<polymer-overlay id="dialog2" class="polymer-overlay-shake" autoCloseDisabled="true">
<h2>Dialog 2</h2>
I'm dizzy.
</div><br><br>
<div id="dialog2" class="dialog polymer-overlay-shake" autoCloseDisabled="true">
<polymer-overlay></polymer-overlay>
<div>
<h2>Dialog 2</h2>
I'm dizzy.
</div>
<br><br>
<button overlay-toggle>OK</button>
</polymer-overlay>
</div>
<script>
setupOverlays = function() {
var overlays = document.querySelectorAll('polymer-overlay');
Array.prototype.forEach.call(overlays, function(o) {
o.target = o.parentNode;
});
}

document.addEventListener('WebComponentsReady', function() {
setupOverlays();
});

$ = document.querySelector.bind(document);

somethingCheck = function() {
$('#confirmation').opened = (event.target.value == 'something');
$('#confirmation').querySelector('polymer-overlay').opened = (event.target.value == 'something');
}

changeOpening = function(e) {
Expand All @@ -101,7 +117,7 @@ <h2>Dialog 2</h2>
b.addEventListener('tap', function(e) {
var overlay = document.querySelector(e.target.getAttribute('overlay'));
if (overlay) {
overlay.toggle();
overlay.querySelector('polymer-overlay').toggle();
}
})
});
Expand Down
38 changes: 38 additions & 0 deletions polymer-overlay/polymer-overlay-global.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,44 @@
* license that can be found in the LICENSE file.
*/

.polymer-overlay {
position: fixed;
z-index: 10;
outline: none;
display: none;
opacity: 0.99;
-webkit-transition: opacity 0.001s;
transition: opacity 0.001s;
}

/*
The revealed class exists because it's necessary to 'show' a node
before applying a transition. When an overlay is opened, it is
immediately revealed (display: block) and then asynchronously the
opened or closing classes are added.
Because we don't want to actually show the node before a transition
or animation is applied, when the node is
revealed, it is made display: block but visibility: hidden.
It is then made visibility: visible when it is opened.
*/

.polymer-overlay.revealed {
display: block;
visibility: hidden;
}

.polymer-overlay.revealed.opened {
opacity: 1;
display: block;
visibility: visible;
}

.polymer-overlay.revealed.closing {
display: block;
visibility: visible;
}

@-webkit-keyframes polymer-overlay-shakeFadeIn {
0% {
opacity: 0;
Expand Down
Loading

0 comments on commit a385ebf

Please sign in to comment.