engram-popup 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engram-popup.es.js +59 -1
- package/dist/engram-popup.umd.js +2 -2
- package/package.json +1 -1
package/dist/engram-popup.es.js
CHANGED
|
@@ -1 +1,59 @@
|
|
|
1
|
-
|
|
1
|
+
function h() {
|
|
2
|
+
const l = document.querySelectorAll("[data-engram-button]");
|
|
3
|
+
if (console.log(l.length), !l || l.length < 1) return;
|
|
4
|
+
let i = null;
|
|
5
|
+
const r = document.querySelectorAll(["[data-engram-popup]"]);
|
|
6
|
+
console.log(r[0]);
|
|
7
|
+
for (let e = 0; e < l.length; e++)
|
|
8
|
+
l[e].addEventListener("click", () => {
|
|
9
|
+
const n = l[e].getAttribute("data-engram-button");
|
|
10
|
+
i != n && s().then((o) => {
|
|
11
|
+
console.log(o), o === !0 && c(n);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
function c(e) {
|
|
15
|
+
let n = null;
|
|
16
|
+
for (let o = 0; o < r.length; o++) {
|
|
17
|
+
let t = r[o].getAttribute("data-engram-popup");
|
|
18
|
+
if (e === t) {
|
|
19
|
+
n = r[o];
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
n ? d(n) : alert(`popup container with name ${e} dont finded`);
|
|
24
|
+
}
|
|
25
|
+
function d(e) {
|
|
26
|
+
let n = e.cloneNode(!0);
|
|
27
|
+
i = n.getAttribute("data-engram-popup");
|
|
28
|
+
let o = n.getAttribute("data-engram-theme") ?? "white";
|
|
29
|
+
n.getAttribute("data-engram-animation");
|
|
30
|
+
let t = document.createElement("div"), p = document.createElement("div");
|
|
31
|
+
p.classList.add("engram-popup__close"), t.classList.add("engram-popup"), o == "white" ? t.classList.add("engram-popup--theme-white") : o == "black" ? t.classList.add("engram-popup--theme-black") : t.classList.add("engram-popup--theme-white"), n.removeAttribute("data-engram-popup"), t.appendChild(p), t.appendChild(n), t.style.visibility = "hidden", document.body.appendChild(t);
|
|
32
|
+
let g = t.clientHeight, u = window.innerHeight;
|
|
33
|
+
console.log(u), t.style.visibility = "", t.style.transform = `translateY(${+u / 2 - +g / 2}px)`, p.addEventListener("click", m), setTimeout(() => {
|
|
34
|
+
document.addEventListener("click", a);
|
|
35
|
+
}, 0);
|
|
36
|
+
}
|
|
37
|
+
function a(e) {
|
|
38
|
+
e.target.closest(".engram-popup") || (s(), console.log("click outside"));
|
|
39
|
+
}
|
|
40
|
+
function m() {
|
|
41
|
+
let e = this.closest(".engram-popup");
|
|
42
|
+
e.style.transform = "translateY(110vh)", setTimeout(() => {
|
|
43
|
+
e.style.visibility = "", e.remove(), i = null, document.removeEventListener("click", a), console.log("close current popup");
|
|
44
|
+
}, 500);
|
|
45
|
+
}
|
|
46
|
+
function s() {
|
|
47
|
+
const e = Array.from(document.querySelectorAll(".engram-popup"));
|
|
48
|
+
if (document.removeEventListener("click", a), e.length < 1) return Promise.resolve(!0);
|
|
49
|
+
const n = e.map((o) => new Promise((t, p) => {
|
|
50
|
+
o.style.transform = "translateY(110vh)", setTimeout(() => {
|
|
51
|
+
o.style.visibility = "", o.remove(), i = null, t();
|
|
52
|
+
}, 500);
|
|
53
|
+
}));
|
|
54
|
+
return Promise.all(n).then(() => !0);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
h as popup
|
|
59
|
+
};
|
package/dist/engram-popup.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
/*$vite$:1*/`,document.head.appendChild(e)}));
|
|
1
|
+
(function(i,p){typeof exports=="object"&&typeof module<"u"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(i=typeof globalThis<"u"?globalThis:i||self,p(i["engram-popup"]={}))})(this,(function(i){"use strict";var p=document.createElement("style");p.textContent=`[data-engram-popup]{display:none}.engram-popup{width:600px;z-index:999;background:#fff;border-radius:20px;position:fixed;box-shadow:0 0 10px #0000001a;left:calc(50% - 300px);padding:30px;transform:translateY(110vh);transition:all ease .5s}.engram-popup--theme-black{background:#222}.engram-popup__close{position:absolute;width:35px;height:35px;border-radius:100px;display:flex;align-items:center;justify-content:center;background:#ccc;right:10px;top:10px;cursor:pointer}
|
|
2
|
+
/*$vite$:1*/`,document.head.appendChild(p);function m(){const l=document.querySelectorAll("[data-engram-button]");if(console.log(l.length),!l||l.length<1)return;let r=null;const a=document.querySelectorAll(["[data-engram-popup]"]);console.log(a[0]);for(let e=0;e<l.length;e++)l[e].addEventListener("click",()=>{const n=l[e].getAttribute("data-engram-button");r!=n&&c().then(o=>{console.log(o),o===!0&&g(n)})});function g(e){let n=null;for(let o=0;o<a.length;o++){let t=a[o].getAttribute("data-engram-popup");if(e===t){n=a[o];break}}n?f(n):alert(`popup container with name ${e} dont finded`)}function f(e){let n=e.cloneNode(!0);r=n.getAttribute("data-engram-popup");let o=n.getAttribute("data-engram-theme")??"white";n.getAttribute("data-engram-animation");let t=document.createElement("div"),s=document.createElement("div");s.classList.add("engram-popup__close"),t.classList.add("engram-popup"),o=="white"?t.classList.add("engram-popup--theme-white"):o=="black"?t.classList.add("engram-popup--theme-black"):t.classList.add("engram-popup--theme-white"),n.removeAttribute("data-engram-popup"),t.appendChild(s),t.appendChild(n),t.style.visibility="hidden",document.body.appendChild(t);let b=t.clientHeight,d=window.innerHeight;console.log(d),t.style.visibility="",t.style.transform=`translateY(${+d/2-+b/2}px)`,s.addEventListener("click",h),setTimeout(()=>{document.addEventListener("click",u)},0)}function u(e){e.target.closest(".engram-popup")||(c(),console.log("click outside"))}function h(){let e=this.closest(".engram-popup");e.style.transform="translateY(110vh)",setTimeout(()=>{e.style.visibility="",e.remove(),r=null,document.removeEventListener("click",u),console.log("close current popup")},500)}function c(){const e=Array.from(document.querySelectorAll(".engram-popup"));if(document.removeEventListener("click",u),e.length<1)return Promise.resolve(!0);const n=e.map(o=>new Promise((t,s)=>{o.style.transform="translateY(110vh)",setTimeout(()=>{o.style.visibility="",o.remove(),r=null,t()},500)}));return Promise.all(n).then(()=>!0)}}i.popup=m,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
|