update components
This commit is contained in:
parent
c2d70081cf
commit
d4301f7089
16 changed files with 863 additions and 173 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "iron-overlay-behavior",
|
||||
"version": "1.6.5",
|
||||
"version": "1.7.0",
|
||||
"license": "http://polymer.github.io/LICENSE.txt",
|
||||
"description": "Provides a behavior for making an element an overlay",
|
||||
"private": true,
|
||||
|
@ -35,11 +35,11 @@
|
|||
},
|
||||
"ignore": [],
|
||||
"homepage": "https://github.com/polymerelements/iron-overlay-behavior",
|
||||
"_release": "1.6.5",
|
||||
"_release": "1.7.0",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v1.6.5",
|
||||
"commit": "19311400fe42fe3992fb8925dfd2582c63c67d82"
|
||||
"tag": "v1.7.0",
|
||||
"commit": "d61575162a40904914fa3528ba20bb531d098001"
|
||||
},
|
||||
"_source": "git://github.com/polymerelements/iron-overlay-behavior.git",
|
||||
"_target": "^1.0.0",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "iron-overlay-behavior",
|
||||
"version": "1.6.5",
|
||||
"version": "1.7.0",
|
||||
"license": "http://polymer.github.io/LICENSE.txt",
|
||||
"description": "Provides a behavior for making an element an overlay",
|
||||
"private": true,
|
||||
|
|
|
@ -9,7 +9,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
-->
|
||||
|
||||
<link rel="import" href="../polymer/polymer.html">
|
||||
<link rel="import" href="iron-overlay-manager.html">
|
||||
|
||||
<!--
|
||||
`iron-overlay-backdrop` is a backdrop used by `Polymer.IronOverlayBehavior`. It should be a
|
||||
|
@ -30,7 +29,6 @@ Custom property | Description | Default
|
|||
<dom-module id="iron-overlay-backdrop">
|
||||
|
||||
<style>
|
||||
|
||||
:host {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
|
@ -41,17 +39,14 @@ Custom property | Description | Default
|
|||
opacity: 0;
|
||||
transition: opacity 0.2s;
|
||||
pointer-events: none;
|
||||
|
||||
@apply(--iron-overlay-backdrop);
|
||||
}
|
||||
|
||||
:host([opened]) {
|
||||
:host(.opened) {
|
||||
opacity: var(--iron-overlay-backdrop-opacity, 0.6);
|
||||
pointer-events: auto;
|
||||
|
||||
@apply(--iron-overlay-backdrop-opened);
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<template>
|
||||
|
@ -61,8 +56,8 @@ Custom property | Description | Default
|
|||
</dom-module>
|
||||
|
||||
<script>
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
Polymer({
|
||||
|
||||
|
@ -74,75 +69,94 @@ Custom property | Description | Default
|
|||
* Returns true if the backdrop is opened.
|
||||
*/
|
||||
opened: {
|
||||
readOnly: true,
|
||||
reflectToAttribute: true,
|
||||
type: Boolean,
|
||||
value: false
|
||||
},
|
||||
|
||||
_manager: {
|
||||
type: Object,
|
||||
value: Polymer.IronOverlayManager
|
||||
value: false,
|
||||
observer: '_openedChanged'
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
listeners: {
|
||||
'transitionend' : '_onTransitionend'
|
||||
'transitionend': '_onTransitionend'
|
||||
},
|
||||
|
||||
created: function() {
|
||||
// Used to cancel previous requestAnimationFrame calls when opened changes.
|
||||
this.__openedRaf = null;
|
||||
},
|
||||
|
||||
attached: function() {
|
||||
this.opened && this._openedChanged(this.opened);
|
||||
},
|
||||
|
||||
/**
|
||||
* Appends the backdrop to document body and sets its `z-index` to be below the latest overlay.
|
||||
* Appends the backdrop to document body if needed.
|
||||
*/
|
||||
prepare: function() {
|
||||
if (!this.parentNode) {
|
||||
if (this.opened && !this.parentNode) {
|
||||
Polymer.dom(document.body).appendChild(this);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Shows the backdrop if needed.
|
||||
* Shows the backdrop.
|
||||
*/
|
||||
open: function() {
|
||||
// only need to make the backdrop visible if this is called by the first overlay with a backdrop
|
||||
if (this._manager.getBackdrops().length < 2) {
|
||||
this._setOpened(true);
|
||||
}
|
||||
this.opened = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Hides the backdrop if needed.
|
||||
* Hides the backdrop.
|
||||
*/
|
||||
close: function() {
|
||||
// close only if no element with backdrop is left
|
||||
if (this._manager.getBackdrops().length === 0) {
|
||||
// Read style before setting opened.
|
||||
var cs = getComputedStyle(this);
|
||||
var noAnimation = (cs.transitionDuration === '0s' || cs.opacity == 0);
|
||||
this._setOpened(false);
|
||||
// In case of no animations, complete
|
||||
if (noAnimation) {
|
||||
this.complete();
|
||||
}
|
||||
}
|
||||
this.opened = false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes the backdrop from document body if needed.
|
||||
*/
|
||||
complete: function() {
|
||||
// only remove the backdrop if there are no more overlays with backdrops
|
||||
if (this._manager.getBackdrops().length === 0 && this.parentNode) {
|
||||
if (!this.opened && this.parentNode === document.body) {
|
||||
Polymer.dom(this.parentNode).removeChild(this);
|
||||
}
|
||||
},
|
||||
|
||||
_onTransitionend: function (event) {
|
||||
_onTransitionend: function(event) {
|
||||
if (event && event.target === this) {
|
||||
this.complete();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_openedChanged: function() {
|
||||
if (this.opened) {
|
||||
// Auto-attach.
|
||||
this.prepare();
|
||||
} else {
|
||||
// Animation might be disabled via the mixin or opacity custom property.
|
||||
// If it is disabled in other ways, it's up to the user to call complete.
|
||||
var cs = window.getComputedStyle(this);
|
||||
if (cs.transitionDuration === '0s' || cs.opacity == 0) {
|
||||
this.complete();
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.isAttached) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Always cancel previous requestAnimationFrame.
|
||||
if (this.__openedRaf) {
|
||||
window.cancelAnimationFrame(this.__openedRaf);
|
||||
this.__openedRaf = null;
|
||||
}
|
||||
// Force relayout to ensure proper transitions.
|
||||
this.scrollTop = this.scrollTop;
|
||||
this.__openedRaf = window.requestAnimationFrame(function() {
|
||||
this.__openedRaf = null;
|
||||
this.toggleClass('opened', this.opened);
|
||||
}.bind(this));
|
||||
}
|
||||
});
|
||||
|
||||
})();
|
||||
|
|
|
@ -11,11 +11,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
<link rel="import" href="../polymer/polymer.html">
|
||||
<link rel="import" href="../iron-fit-behavior/iron-fit-behavior.html">
|
||||
<link rel="import" href="../iron-resizable-behavior/iron-resizable-behavior.html">
|
||||
<link rel="import" href="iron-overlay-backdrop.html">
|
||||
<link rel="import" href="iron-overlay-manager.html">
|
||||
|
||||
<script>
|
||||
// IIFE to help scripts concatenation.
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
|
@ -257,10 +255,6 @@ context. You should place this element as a child of `<body>` whenever possible.
|
|||
Polymer.dom(this).unobserveNodes(this._observer);
|
||||
this._observer = null;
|
||||
this.opened = false;
|
||||
if (this.withBackdrop) {
|
||||
// Allow user interactions right away.
|
||||
this.backdropElement.close();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -337,9 +331,6 @@ context. You should place this element as a child of `<body>` whenever possible.
|
|||
this.__isAnimating = true;
|
||||
|
||||
if (this.opened) {
|
||||
if (this.withBackdrop) {
|
||||
this.backdropElement.prepare();
|
||||
}
|
||||
// requestAnimationFrame for non-blocking rendering
|
||||
this.__openChangedAsync = window.requestAnimationFrame(function() {
|
||||
this.__openChangedAsync = null;
|
||||
|
@ -367,15 +358,6 @@ context. You should place this element as a child of `<body>` whenever possible.
|
|||
}
|
||||
if (this.opened) {
|
||||
this._manager.trackBackdrop();
|
||||
if (this.withBackdrop) {
|
||||
this.backdropElement.prepare();
|
||||
// Give time to be added to document.
|
||||
this.async(function(){
|
||||
this.backdropElement.open();
|
||||
}, 1);
|
||||
} else {
|
||||
this.backdropElement.close();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -403,9 +385,6 @@ context. You should place this element as a child of `<body>` whenever possible.
|
|||
* @protected
|
||||
*/
|
||||
_renderOpened: function() {
|
||||
if (this.withBackdrop) {
|
||||
this.backdropElement.open();
|
||||
}
|
||||
this._finishRenderOpened();
|
||||
},
|
||||
|
||||
|
@ -414,9 +393,6 @@ context. You should place this element as a child of `<body>` whenever possible.
|
|||
* @protected
|
||||
*/
|
||||
_renderClosed: function() {
|
||||
if (this.withBackdrop) {
|
||||
this.backdropElement.close();
|
||||
}
|
||||
this._finishRenderClosed();
|
||||
},
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
|
||||
<link rel="import" href="../polymer/polymer.html">
|
||||
<link rel="import" href="../iron-a11y-keys-behavior/iron-a11y-keys-behavior.html">
|
||||
<link rel="import" href="iron-overlay-backdrop.html">
|
||||
|
||||
<script>
|
||||
|
||||
|
@ -224,7 +225,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
* Updates the backdrop z-index.
|
||||
*/
|
||||
trackBackdrop: function() {
|
||||
this.backdropElement.style.zIndex = this.backdropZ();
|
||||
var overlay = this._overlayWithBackdrop();
|
||||
// Avoid creating the backdrop if there is no overlay with backdrop.
|
||||
if (!overlay && !this._backdropElement) {
|
||||
return;
|
||||
}
|
||||
this.backdropElement.style.zIndex = this._getZ(overlay) - 1;
|
||||
this.backdropElement.opened = !!overlay;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -700,10 +700,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
});
|
||||
|
||||
test('backdrop is opened when overlay is opened', function(done) {
|
||||
assert.isDefined(overlay.backdropElement, 'backdrop is defined');
|
||||
assert.isOk(overlay.backdropElement, 'backdrop is defined');
|
||||
runAfterOpen(overlay, function() {
|
||||
assert.isTrue(overlay.backdropElement.opened, 'backdrop is opened');
|
||||
assert.isDefined(overlay.backdropElement.parentNode, 'backdrop is inserted in the DOM');
|
||||
assert.isOk(overlay.backdropElement.parentNode, 'backdrop is inserted in the DOM');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue