modal: add popupLeft and popupTop properties (#265)

This commit is contained in:
jean-emmanuel 2018-04-06 18:08:07 +02:00
parent 7ac6bdefd4
commit 711688df7f
5 changed files with 48 additions and 10 deletions

View file

@ -31,6 +31,8 @@ module.exports = class Modal extends Panel {
popupLabel:'',
popupWidth:'80%',
popupHeight:'80%',
popupLeft:'auto',
popupTop:'auto',
layout:'',
spacing:0,
@ -74,11 +76,23 @@ module.exports = class Modal extends Panel {
this.container.appendChild(this.popup)
// convert dimensions / coordinates to rem
var width = parseFloat(this.getProp('popupWidth'))==this.getProp('popupWidth')?parseFloat(this.getProp('popupWidth'))+'rem' : this.getProp('popupWidth'),
height = parseFloat(this.getProp('popupHeight'))==this.getProp('popupHeight')?parseFloat(this.getProp('popupHeight'))+'rem' : this.getProp('popupHeight')
var geometry = {}
for (var g of ['Width', 'Height', 'Left', 'Top']) {
geometry[g] = parseFloat(this.getProp('popup' + g)) == this.getProp('popup' + g) ? parseFloat(this.getProp('popup' + g)) + 'rem' : this.getProp('popup' + g)
}
this.popup.style.setProperty('--width', width)
this.popup.style.setProperty('--height', height)
this.popup.style.setProperty('--width', geometry.Width)
this.popup.style.setProperty('--height', geometry.Height)
if (geometry.Left !== 'auto') {
this.popup.style.setProperty('--left', geometry.Left)
this.popup.classList.add('x-positionned')
}
if (geometry.Top !== 'auto') {
this.popup.style.setProperty('--top', geometry.Top)
this.popup.classList.add('y-positionned')
}
DOM.get(this.popup, '.closer')[0].addEventListener('fast-click', (e)=>{
e.detail.preventDefault = true

View file

@ -496,7 +496,8 @@ body {
right:0;
bottom:0;
padding:10%;
align-items: center;
align-items:center;
justify-content: center;
z-index:1000000;
transform: translate3d(0,0,0);
display: none;
@ -506,10 +507,10 @@ body {
&:before {
content: "";
position: absolute;
top:-40rem;
left:-40rem;
right:-40rem;
bottom:-40rem;
top:0;
left:0;
right:0;
bottom:0;
background:var(--color-bg);
opacity: .5;
}
@ -544,7 +545,6 @@ body {
align-items: stretch;
width:auto;
max-width:600rem;
margin:0 auto;
position: relative;
overflow: hidden;
box-shadow: 1rem 0 0 0 var(--color-bg),

View file

@ -201,6 +201,7 @@
}
> .popup {
padding:0;
> .popup-wrapper {
max-width: 100%;
max-height: 100%;
@ -224,6 +225,20 @@
z-index: 1;
}
}
&.x-positionned {
justify-content: flex-start;
> .popup-wrapper {
margin-left: var(--left);
}
}
&.y-positionned {
align-items:flex-start;
> .popup-wrapper {
margin-top: var(--top);
}
}
}
&.editing .popup-wrapper:after {
content:"";