mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
update components
This commit is contained in:
parent
c2d70081cf
commit
d4301f7089
16 changed files with 863 additions and 173 deletions
|
@ -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));
|
||||
}
|
||||
});
|
||||
|
||||
})();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue