react-iframe-plugin 0.1.3 → 0.1.5
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/index.d.ts +2 -2
- package/dist/index.es.js +67 -82
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,10 +3,10 @@ interface IframePluginProps {
|
|
|
3
3
|
src: string;
|
|
4
4
|
title?: string;
|
|
5
5
|
width?: string;
|
|
6
|
-
height
|
|
6
|
+
height?: string;
|
|
7
7
|
types?: string;
|
|
8
8
|
iframeDomain: string;
|
|
9
|
-
basicHeight
|
|
9
|
+
basicHeight?: string;
|
|
10
10
|
url: string;
|
|
11
11
|
newWindow?: boolean;
|
|
12
12
|
zIndex?: string;
|
package/dist/index.es.js
CHANGED
|
@@ -1,129 +1,114 @@
|
|
|
1
|
-
import { jsx as l, Fragment as b
|
|
2
|
-
import { useState as
|
|
3
|
-
const L = (
|
|
4
|
-
const [
|
|
5
|
-
zIndex:
|
|
6
|
-
newWindow:
|
|
1
|
+
import { jsx as l, Fragment as b } from "react/jsx-runtime";
|
|
2
|
+
import { useState as d, useRef as B, useEffect as w } from "react";
|
|
3
|
+
const L = (x) => {
|
|
4
|
+
const [m, h] = d("250px"), [E, S] = d("250px"), {
|
|
5
|
+
zIndex: y,
|
|
6
|
+
newWindow: a,
|
|
7
7
|
url: c,
|
|
8
8
|
basicHeight: o,
|
|
9
9
|
iframeDomain: n,
|
|
10
10
|
// currentDomain,
|
|
11
|
-
types:
|
|
12
|
-
src:
|
|
13
|
-
title:
|
|
14
|
-
width:
|
|
15
|
-
height:
|
|
16
|
-
} =
|
|
17
|
-
|
|
18
|
-
const t =
|
|
11
|
+
types: i,
|
|
12
|
+
src: f,
|
|
13
|
+
title: u,
|
|
14
|
+
width: g,
|
|
15
|
+
height: s
|
|
16
|
+
} = x, r = B(!1), [F, H] = d(!1);
|
|
17
|
+
w(() => {
|
|
18
|
+
const t = i == "footer" ? document.getElementById("iframeFooter") : document.getElementById("iframePlugin");
|
|
19
19
|
console.log(
|
|
20
20
|
87878787,
|
|
21
21
|
t.contentWindow,
|
|
22
22
|
// currentDomain,
|
|
23
23
|
n,
|
|
24
24
|
c,
|
|
25
|
-
|
|
25
|
+
s,
|
|
26
26
|
o,
|
|
27
|
-
|
|
27
|
+
a
|
|
28
28
|
), t.addEventListener("load", function() {
|
|
29
|
-
console.log("currentDomain────────────", o),
|
|
29
|
+
console.log("currentDomain────────────", o), h(o || "250px");
|
|
30
30
|
const e = window.location.origin;
|
|
31
31
|
e && t.contentWindow.postMessage(
|
|
32
32
|
{
|
|
33
33
|
currentDomain: e,
|
|
34
34
|
iframeDomain: n || "http://localhost:8086",
|
|
35
35
|
url: c || "http://localhost:8081",
|
|
36
|
-
height:
|
|
36
|
+
height: s || "800px",
|
|
37
37
|
basicHeight: o,
|
|
38
|
-
newWindow:
|
|
38
|
+
newWindow: a || !0
|
|
39
39
|
},
|
|
40
40
|
n || "http://localhost:8086"
|
|
41
|
-
),
|
|
42
|
-
|
|
41
|
+
), p(), window.addEventListener("scroll", (D) => {
|
|
42
|
+
p();
|
|
43
43
|
});
|
|
44
44
|
}), window.addEventListener("message", function(e) {
|
|
45
45
|
console.log("message", e), console.log(
|
|
46
46
|
"plugin Fetch iframe:",
|
|
47
47
|
e.data.height,
|
|
48
48
|
e.data.footerHeight
|
|
49
|
-
), e.data && (e.data.height &&
|
|
49
|
+
), e.data && (e.data.height && h(e.data.height || o), e.data.footerHeight && S(e.data.footerHeight));
|
|
50
50
|
});
|
|
51
51
|
}, []);
|
|
52
|
-
const
|
|
53
|
-
var t =
|
|
54
|
-
t > Number(
|
|
52
|
+
const I = () => (document.scrollingElement || document.documentElement).scrollTop, p = () => {
|
|
53
|
+
var t = I();
|
|
54
|
+
t > Number(m.replace("px", "")) ? r.current = !0 : r.current = !1, H(r.current);
|
|
55
55
|
};
|
|
56
|
-
return
|
|
57
|
-
console.log("isScroll",
|
|
56
|
+
return w(() => {
|
|
57
|
+
console.log("isScroll", r.current), (i == "footer" ? document.getElementById("iframeFooter") : document.getElementById("iframePlugin")).contentWindow.postMessage(
|
|
58
58
|
{
|
|
59
59
|
currentDomain: window.location.origin,
|
|
60
60
|
iframeDomain: n || "http://localhost:8086",
|
|
61
61
|
url: c || "http://localhost:8081",
|
|
62
|
-
height:
|
|
62
|
+
height: s || "800px",
|
|
63
63
|
basicHeight: o,
|
|
64
|
-
newWindow:
|
|
65
|
-
isScroll:
|
|
64
|
+
newWindow: a || !0,
|
|
65
|
+
isScroll: r.current
|
|
66
66
|
},
|
|
67
67
|
n || "http://localhost:8086"
|
|
68
68
|
);
|
|
69
|
-
}, [F]), /* @__PURE__ */ l(b, { children: /* @__PURE__ */
|
|
69
|
+
}, [F]), /* @__PURE__ */ l(b, { children: /* @__PURE__ */ l(
|
|
70
70
|
"div",
|
|
71
71
|
{
|
|
72
72
|
style: {
|
|
73
73
|
width: "100%",
|
|
74
74
|
position: "relative",
|
|
75
|
-
zIndex:
|
|
76
|
-
paddingBottom:
|
|
75
|
+
zIndex: y || 999,
|
|
76
|
+
paddingBottom: i === "footer" ? "0px" : "250px"
|
|
77
77
|
},
|
|
78
|
-
children:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
title: p,
|
|
113
|
-
width: w,
|
|
114
|
-
height: a,
|
|
115
|
-
style: {
|
|
116
|
-
border: "none",
|
|
117
|
-
width: "100vw",
|
|
118
|
-
background: "transparent",
|
|
119
|
-
position: "fixed",
|
|
120
|
-
top: 0,
|
|
121
|
-
left: 0
|
|
122
|
-
},
|
|
123
|
-
allowFullScreen: !0
|
|
124
|
-
}
|
|
125
|
-
)
|
|
126
|
-
]
|
|
78
|
+
children: i === "footer" ? /* @__PURE__ */ l(
|
|
79
|
+
"iframe",
|
|
80
|
+
{
|
|
81
|
+
id: "iframeFooter",
|
|
82
|
+
src: f,
|
|
83
|
+
title: u,
|
|
84
|
+
width: g,
|
|
85
|
+
height: E,
|
|
86
|
+
style: {
|
|
87
|
+
border: "none",
|
|
88
|
+
width: "100vw",
|
|
89
|
+
background: "transparent"
|
|
90
|
+
},
|
|
91
|
+
allowFullScreen: !0
|
|
92
|
+
}
|
|
93
|
+
) : /* @__PURE__ */ l(
|
|
94
|
+
"iframe",
|
|
95
|
+
{
|
|
96
|
+
id: "iframePlugin",
|
|
97
|
+
src: f,
|
|
98
|
+
title: u,
|
|
99
|
+
width: g,
|
|
100
|
+
height: m,
|
|
101
|
+
style: {
|
|
102
|
+
border: "none",
|
|
103
|
+
width: "100vw",
|
|
104
|
+
background: "transparent",
|
|
105
|
+
position: "fixed",
|
|
106
|
+
top: 0,
|
|
107
|
+
left: 0
|
|
108
|
+
},
|
|
109
|
+
allowFullScreen: !0
|
|
110
|
+
}
|
|
111
|
+
)
|
|
127
112
|
}
|
|
128
113
|
) });
|
|
129
114
|
};
|