refactoring popup component code

This commit is contained in:
sairaj mote 2022-01-28 23:22:57 +05:30
parent 7afbf8257f
commit afde9d4a1c

View File

@ -992,7 +992,6 @@ customElements.define('sm-notifications', class extends HTMLElement {
});
class Stack {
constructor() {
this.items = [];
@ -1262,17 +1261,15 @@ customElements.define('sm-popup', class extends HTMLElement {
duration: 300,
easing: 'ease'
}
if (popupStack) {
popupStack.push({
popup: this,
permission: pinned
});
if (popupStack.items.length > 1) {
this.animateTo(popupStack.items[popupStack.items.length - 2].popup.shadowRoot.querySelector('.popup'), [
{ transform: 'none' },
{ transform: 'translateY(-1.5rem) scale(0.9)' },
], animOptions)
}
popupStack.push({
popup: this,
permission: pinned
});
if (popupStack.items.length > 1) {
this.animateTo(popupStack.items[popupStack.items.length - 2].popup.shadowRoot.querySelector('.popup'), [
{ transform: 'none' },
{ transform: (window.innerWidth > 640) ? 'scale(0.95)' : 'translateY(-1.5rem)' },
], animOptions)
}
this.popupContainer.classList.remove('hide');
if (!this.offset)
@ -1322,20 +1319,6 @@ customElements.define('sm-popup', class extends HTMLElement {
this.popupContainer.classList.add('hide');
this.popup.style = ''
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) {
this.forms.forEach(form => form.reset());
@ -1350,6 +1333,16 @@ customElements.define('sm-popup', class extends HTMLElement {
);
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) {