refactoring popup component code
This commit is contained in:
parent
7afbf8257f
commit
afde9d4a1c
@ -992,7 +992,6 @@ customElements.define('sm-notifications', class extends HTMLElement {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Stack {
|
class Stack {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.items = [];
|
this.items = [];
|
||||||
@ -1262,17 +1261,15 @@ customElements.define('sm-popup', class extends HTMLElement {
|
|||||||
duration: 300,
|
duration: 300,
|
||||||
easing: 'ease'
|
easing: 'ease'
|
||||||
}
|
}
|
||||||
if (popupStack) {
|
popupStack.push({
|
||||||
popupStack.push({
|
popup: this,
|
||||||
popup: this,
|
permission: pinned
|
||||||
permission: pinned
|
});
|
||||||
});
|
if (popupStack.items.length > 1) {
|
||||||
if (popupStack.items.length > 1) {
|
this.animateTo(popupStack.items[popupStack.items.length - 2].popup.shadowRoot.querySelector('.popup'), [
|
||||||
this.animateTo(popupStack.items[popupStack.items.length - 2].popup.shadowRoot.querySelector('.popup'), [
|
{ transform: 'none' },
|
||||||
{ transform: 'none' },
|
{ transform: (window.innerWidth > 640) ? 'scale(0.95)' : 'translateY(-1.5rem)' },
|
||||||
{ transform: 'translateY(-1.5rem) scale(0.9)' },
|
], animOptions)
|
||||||
], animOptions)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.popupContainer.classList.remove('hide');
|
this.popupContainer.classList.remove('hide');
|
||||||
if (!this.offset)
|
if (!this.offset)
|
||||||
@ -1322,20 +1319,6 @@ customElements.define('sm-popup', class extends HTMLElement {
|
|||||||
this.popupContainer.classList.add('hide');
|
this.popupContainer.classList.add('hide');
|
||||||
this.popup.style = ''
|
this.popup.style = ''
|
||||||
this.removeAttribute('open');
|
this.removeAttribute('open');
|
||||||
if (typeof popupStack !== 'undefined') {
|
|
||||||
popupStack.pop();
|
|
||||||
if (popupStack.items.length) {
|
|
||||||
this.animateTo(popupStack.items[popupStack.items.length - 1].popup.shadowRoot.querySelector('.popup'), [
|
|
||||||
{ transform: 'translateY(-1.5rem) scale(0.9)' },
|
|
||||||
{ transform: 'none' },
|
|
||||||
], animOptions)
|
|
||||||
|
|
||||||
} else {
|
|
||||||
this.resumeScrolling();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.resumeScrolling();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.forms.length) {
|
if (this.forms.length) {
|
||||||
this.forms.forEach(form => form.reset());
|
this.forms.forEach(form => form.reset());
|
||||||
@ -1350,6 +1333,16 @@ customElements.define('sm-popup', class extends HTMLElement {
|
|||||||
);
|
);
|
||||||
this.isOpen = false;
|
this.isOpen = false;
|
||||||
})
|
})
|
||||||
|
popupStack.pop();
|
||||||
|
if (popupStack.items.length) {
|
||||||
|
this.animateTo(popupStack.items[popupStack.items.length - 1].popup.shadowRoot.querySelector('.popup'), [
|
||||||
|
{ transform: (window.innerWidth > 640) ? 'scale(0.95)' : 'translateY(-1.5rem)' },
|
||||||
|
{ transform: 'none' },
|
||||||
|
], animOptions)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this.resumeScrolling();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleTouchStart(e) {
|
handleTouchStart(e) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user