@spscommerce/positioning 8.33.1 → 8.33.3
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/lib/index.js +414 -408
- package/lib/index.umd.cjs +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1,431 +1,437 @@
|
|
|
1
|
-
import { onNextTick as
|
|
2
|
-
var
|
|
3
|
-
const
|
|
1
|
+
import { onNextTick as U, lockedToAnimationFrames as j } from "@spscommerce/utils";
|
|
2
|
+
var S = /* @__PURE__ */ ((g) => (g.TOP_LEFT = "top left", g.TOP_MIDDLE = "top middle", g.TOP_RIGHT = "top right", g.RIGHT_TOP = "right top", g.RIGHT_MIDDLE = "right middle", g.RIGHT_BOTTOM = "right bottom", g.BOTTOM_RIGHT = "bottom right", g.BOTTOM_MIDDLE = "bottom middle", g.BOTTOM_LEFT = "bottom left", g.LEFT_BOTTOM = "left bottom", g.LEFT_MIDDLE = "left middle", g.LEFT_TOP = "left top", g))(S || {}), M = /* @__PURE__ */ ((g) => (g.TOP_LEFT = "top left", g.TOP_RIGHT = "top right", g.BOTTOM_LEFT = "bottom left", g.BOTTOM_RIGHT = "bottom right", g))(M || {});
|
|
3
|
+
const V = {
|
|
4
4
|
anchor: M.TOP_LEFT,
|
|
5
5
|
offsets: [],
|
|
6
|
-
position:
|
|
6
|
+
position: S.TOP_LEFT
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"isIntersecting"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
var A = {}, F;
|
|
9
|
+
function q() {
|
|
10
|
+
return F || (F = 1, function() {
|
|
11
|
+
if (typeof window != "object")
|
|
12
|
+
return;
|
|
13
|
+
if ("IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype) {
|
|
14
|
+
"isIntersecting" in window.IntersectionObserverEntry.prototype || Object.defineProperty(
|
|
15
|
+
window.IntersectionObserverEntry.prototype,
|
|
16
|
+
"isIntersecting",
|
|
17
|
+
{
|
|
18
|
+
get: function() {
|
|
19
|
+
return this.intersectionRatio > 0;
|
|
20
|
+
}
|
|
18
21
|
}
|
|
22
|
+
);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
function g(t) {
|
|
26
|
+
try {
|
|
27
|
+
return t.defaultView && t.defaultView.frameElement || null;
|
|
28
|
+
} catch {
|
|
29
|
+
return null;
|
|
19
30
|
}
|
|
20
|
-
);
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
function g(t) {
|
|
24
|
-
try {
|
|
25
|
-
return t.defaultView && t.defaultView.frameElement || null;
|
|
26
|
-
} catch {
|
|
27
|
-
return null;
|
|
28
31
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
o ? this.intersectionRatio = Number((l / o).toFixed(4)) : this.intersectionRatio = this.isIntersecting ? 1 : 0;
|
|
39
|
-
}
|
|
40
|
-
function a(t, e) {
|
|
41
|
-
var o = e || {};
|
|
42
|
-
if (typeof t != "function")
|
|
43
|
-
throw new Error("callback must be a function");
|
|
44
|
-
if (o.root && o.root.nodeType != 1 && o.root.nodeType != 9)
|
|
45
|
-
throw new Error("root must be a Document or Element");
|
|
46
|
-
this._checkForIntersections = d(
|
|
47
|
-
this._checkForIntersections.bind(this),
|
|
48
|
-
this.THROTTLE_TIMEOUT
|
|
49
|
-
), this._callback = t, this._observationTargets = [], this._queuedEntries = [], this._rootMarginValues = this._parseRootMargin(o.rootMargin), this.thresholds = this._initThresholds(o.threshold), this.root = o.root || null, this.rootMargin = this._rootMarginValues.map(function(s) {
|
|
50
|
-
return s.value + s.unit;
|
|
51
|
-
}).join(" "), this._monitoringDocuments = [], this._monitoringUnsubscribes = [];
|
|
52
|
-
}
|
|
53
|
-
a.prototype.THROTTLE_TIMEOUT = 100, a.prototype.POLL_INTERVAL = null, a.prototype.USE_MUTATION_OBSERVER = !0, a._setupCrossOriginUpdater = function() {
|
|
54
|
-
return p || (p = function(t, e) {
|
|
55
|
-
!t || !e ? f = y() : f = x(t, e), i.forEach(function(o) {
|
|
56
|
-
o._checkForIntersections();
|
|
57
|
-
});
|
|
58
|
-
}), p;
|
|
59
|
-
}, a._resetCrossOriginUpdater = function() {
|
|
60
|
-
p = null, f = null;
|
|
61
|
-
}, a.prototype.observe = function(t) {
|
|
62
|
-
var e = this._observationTargets.some(function(o) {
|
|
63
|
-
return o.element == t;
|
|
64
|
-
});
|
|
65
|
-
if (!e) {
|
|
66
|
-
if (!(t && t.nodeType == 1))
|
|
67
|
-
throw new Error("target must be an Element");
|
|
68
|
-
this._registerInstance(), this._observationTargets.push({ element: t, entry: null }), this._monitorIntersections(t.ownerDocument), this._checkForIntersections();
|
|
32
|
+
var n = function(t) {
|
|
33
|
+
for (var e = t, o = g(e); o; )
|
|
34
|
+
e = o.ownerDocument, o = g(e);
|
|
35
|
+
return e;
|
|
36
|
+
}(window.document), i = [], p = null, f = null;
|
|
37
|
+
function w(t) {
|
|
38
|
+
this.time = t.time, this.target = t.target, this.rootBounds = b(t.rootBounds), this.boundingClientRect = b(t.boundingClientRect), this.intersectionRect = b(t.intersectionRect || y()), this.isIntersecting = !!t.intersectionRect;
|
|
39
|
+
var e = this.boundingClientRect, o = e.width * e.height, s = this.intersectionRect, u = s.width * s.height;
|
|
40
|
+
o ? this.intersectionRatio = Number((u / o).toFixed(4)) : this.intersectionRatio = this.isIntersecting ? 1 : 0;
|
|
69
41
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}, a.prototype._monitorIntersections = function(t) {
|
|
95
|
-
var e = t.defaultView;
|
|
96
|
-
if (e && this._monitoringDocuments.indexOf(t) == -1) {
|
|
97
|
-
var o = this._checkForIntersections, s = null, l = null;
|
|
98
|
-
this.POLL_INTERVAL ? s = e.setInterval(o, this.POLL_INTERVAL) : (c(e, "resize", o, !0), c(t, "scroll", o, !0), this.USE_MUTATION_OBSERVER && "MutationObserver" in e && (l = new e.MutationObserver(o), l.observe(t, {
|
|
99
|
-
attributes: !0,
|
|
100
|
-
childList: !0,
|
|
101
|
-
characterData: !0,
|
|
102
|
-
subtree: !0
|
|
103
|
-
}))), this._monitoringDocuments.push(t), this._monitoringUnsubscribes.push(function() {
|
|
104
|
-
var I = t.defaultView;
|
|
105
|
-
I && (s && I.clearInterval(s), u(I, "resize", o, !0)), u(t, "scroll", o, !0), l && l.disconnect();
|
|
42
|
+
function a(t, e) {
|
|
43
|
+
var o = e || {};
|
|
44
|
+
if (typeof t != "function")
|
|
45
|
+
throw new Error("callback must be a function");
|
|
46
|
+
if (o.root && o.root.nodeType != 1 && o.root.nodeType != 9)
|
|
47
|
+
throw new Error("root must be a Document or Element");
|
|
48
|
+
this._checkForIntersections = d(
|
|
49
|
+
this._checkForIntersections.bind(this),
|
|
50
|
+
this.THROTTLE_TIMEOUT
|
|
51
|
+
), this._callback = t, this._observationTargets = [], this._queuedEntries = [], this._rootMarginValues = this._parseRootMargin(o.rootMargin), this.thresholds = this._initThresholds(o.threshold), this.root = o.root || null, this.rootMargin = this._rootMarginValues.map(function(s) {
|
|
52
|
+
return s.value + s.unit;
|
|
53
|
+
}).join(" "), this._monitoringDocuments = [], this._monitoringUnsubscribes = [];
|
|
54
|
+
}
|
|
55
|
+
a.prototype.THROTTLE_TIMEOUT = 100, a.prototype.POLL_INTERVAL = null, a.prototype.USE_MUTATION_OBSERVER = !0, a._setupCrossOriginUpdater = function() {
|
|
56
|
+
return p || (p = function(t, e) {
|
|
57
|
+
!t || !e ? f = y() : f = x(t, e), i.forEach(function(o) {
|
|
58
|
+
o._checkForIntersections();
|
|
59
|
+
});
|
|
60
|
+
}), p;
|
|
61
|
+
}, a._resetCrossOriginUpdater = function() {
|
|
62
|
+
p = null, f = null;
|
|
63
|
+
}, a.prototype.observe = function(t) {
|
|
64
|
+
var e = this._observationTargets.some(function(o) {
|
|
65
|
+
return o.element == t;
|
|
106
66
|
});
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
67
|
+
if (!e) {
|
|
68
|
+
if (!(t && t.nodeType == 1))
|
|
69
|
+
throw new Error("target must be an Element");
|
|
70
|
+
this._registerInstance(), this._observationTargets.push({ element: t, entry: null }), this._monitorIntersections(t.ownerDocument), this._checkForIntersections();
|
|
111
71
|
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
72
|
+
}, a.prototype.unobserve = function(t) {
|
|
73
|
+
this._observationTargets = this._observationTargets.filter(function(e) {
|
|
74
|
+
return e.element != t;
|
|
75
|
+
}), this._unmonitorIntersections(t.ownerDocument), this._observationTargets.length == 0 && this._unregisterInstance();
|
|
76
|
+
}, a.prototype.disconnect = function() {
|
|
77
|
+
this._observationTargets = [], this._unmonitorAllIntersections(), this._unregisterInstance();
|
|
78
|
+
}, a.prototype.takeRecords = function() {
|
|
79
|
+
var t = this._queuedEntries.slice();
|
|
80
|
+
return this._queuedEntries = [], t;
|
|
81
|
+
}, a.prototype._initThresholds = function(t) {
|
|
82
|
+
var e = t || [0];
|
|
83
|
+
return Array.isArray(e) || (e = [e]), e.sort().filter(function(o, s, u) {
|
|
84
|
+
if (typeof o != "number" || isNaN(o) || o < 0 || o > 1)
|
|
85
|
+
throw new Error("threshold must be a number between 0 and 1 inclusively");
|
|
86
|
+
return o !== u[s - 1];
|
|
126
87
|
});
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
88
|
+
}, a.prototype._parseRootMargin = function(t) {
|
|
89
|
+
var e = t || "0px", o = e.split(/\s+/).map(function(s) {
|
|
90
|
+
var u = /^(-?\d*\.?\d+)(px|%)$/.exec(s);
|
|
91
|
+
if (!u)
|
|
92
|
+
throw new Error("rootMargin must be specified in pixels or percent");
|
|
93
|
+
return { value: parseFloat(u[1]), unit: u[2] };
|
|
94
|
+
});
|
|
95
|
+
return o[1] = o[1] || o[0], o[2] = o[2] || o[0], o[3] = o[3] || o[1], o;
|
|
96
|
+
}, a.prototype._monitorIntersections = function(t) {
|
|
97
|
+
var e = t.defaultView;
|
|
98
|
+
if (e && this._monitoringDocuments.indexOf(t) == -1) {
|
|
99
|
+
var o = this._checkForIntersections, s = null, u = null;
|
|
100
|
+
this.POLL_INTERVAL ? s = e.setInterval(o, this.POLL_INTERVAL) : (c(e, "resize", o, !0), c(t, "scroll", o, !0), this.USE_MUTATION_OBSERVER && "MutationObserver" in e && (u = new e.MutationObserver(o), u.observe(t, {
|
|
101
|
+
attributes: !0,
|
|
102
|
+
childList: !0,
|
|
103
|
+
characterData: !0,
|
|
104
|
+
subtree: !0
|
|
105
|
+
}))), this._monitoringDocuments.push(t), this._monitoringUnsubscribes.push(function() {
|
|
106
|
+
var I = t.defaultView;
|
|
107
|
+
I && (s && I.clearInterval(s), l(I, "resize", o, !0)), l(t, "scroll", o, !0), u && u.disconnect();
|
|
108
|
+
});
|
|
109
|
+
var O = this.root && (this.root.ownerDocument || this.root) || n;
|
|
110
|
+
if (t != O) {
|
|
111
|
+
var E = g(t);
|
|
112
|
+
E && this._monitorIntersections(E.ownerDocument);
|
|
132
113
|
}
|
|
133
114
|
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
time: m(),
|
|
148
|
-
target: s,
|
|
149
|
-
boundingClientRect: l,
|
|
150
|
-
rootBounds: L,
|
|
151
|
-
intersectionRect: I
|
|
115
|
+
}, a.prototype._unmonitorIntersections = function(t) {
|
|
116
|
+
var e = this._monitoringDocuments.indexOf(t);
|
|
117
|
+
if (e != -1) {
|
|
118
|
+
var o = this.root && (this.root.ownerDocument || this.root) || n, s = this._observationTargets.some(function(E) {
|
|
119
|
+
var I = E.element.ownerDocument;
|
|
120
|
+
if (I == t)
|
|
121
|
+
return !0;
|
|
122
|
+
for (; I && I != o; ) {
|
|
123
|
+
var L = g(I);
|
|
124
|
+
if (I = L && L.ownerDocument, I == t)
|
|
125
|
+
return !0;
|
|
126
|
+
}
|
|
127
|
+
return !1;
|
|
152
128
|
});
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
129
|
+
if (!s) {
|
|
130
|
+
var u = this._monitoringUnsubscribes[e];
|
|
131
|
+
if (this._monitoringDocuments.splice(e, 1), this._monitoringUnsubscribes.splice(e, 1), u(), t != o) {
|
|
132
|
+
var O = g(t);
|
|
133
|
+
O && this._unmonitorIntersections(O.ownerDocument);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}, a.prototype._unmonitorAllIntersections = function() {
|
|
138
|
+
var t = this._monitoringUnsubscribes.slice(0);
|
|
139
|
+
this._monitoringDocuments.length = 0, this._monitoringUnsubscribes.length = 0;
|
|
140
|
+
for (var e = 0; e < t.length; e++)
|
|
141
|
+
t[e]();
|
|
142
|
+
}, a.prototype._checkForIntersections = function() {
|
|
143
|
+
if (!(!this.root && p && !f)) {
|
|
144
|
+
var t = this._rootIsInDom(), e = t ? this._getRootRect() : y();
|
|
145
|
+
this._observationTargets.forEach(function(o) {
|
|
146
|
+
var s = o.element, u = T(s), O = this._rootContainsTarget(s), E = o.entry, I = t && O && this._computeTargetAndRootIntersection(s, u, e), L = null;
|
|
147
|
+
this._rootContainsTarget(s) ? (!p || this.root) && (L = e) : L = y();
|
|
148
|
+
var D = o.entry = new w({
|
|
149
|
+
time: m(),
|
|
150
|
+
target: s,
|
|
151
|
+
boundingClientRect: u,
|
|
152
|
+
rootBounds: L,
|
|
153
|
+
intersectionRect: I
|
|
154
|
+
});
|
|
155
|
+
E ? t && O ? this._hasCrossedThreshold(E, D) && this._queuedEntries.push(D) : E && E.isIntersecting && this._queuedEntries.push(D) : this._queuedEntries.push(D);
|
|
156
|
+
}, this), this._queuedEntries.length && this._callback(this.takeRecords(), this);
|
|
157
|
+
}
|
|
158
|
+
}, a.prototype._computeTargetAndRootIntersection = function(t, e, o) {
|
|
159
|
+
if (window.getComputedStyle(t).display != "none") {
|
|
160
|
+
for (var s = e, u = _(t), O = !1; !O && u; ) {
|
|
161
|
+
var E = null, I = u.nodeType == 1 ? window.getComputedStyle(u) : {};
|
|
162
|
+
if (I.display == "none") return null;
|
|
163
|
+
if (u == this.root || u.nodeType == /* DOCUMENT */
|
|
164
|
+
9)
|
|
165
|
+
if (O = !0, u == this.root || u == n)
|
|
166
|
+
p && !this.root ? !f || f.width == 0 && f.height == 0 ? (u = null, E = null, s = null) : E = f : E = o;
|
|
167
|
+
else {
|
|
168
|
+
var L = _(u), D = L && T(L), B = L && this._computeTargetAndRootIntersection(L, D, o);
|
|
169
|
+
D && B ? (u = L, E = x(D, B)) : (u = null, s = null);
|
|
170
|
+
}
|
|
165
171
|
else {
|
|
166
|
-
var
|
|
167
|
-
|
|
172
|
+
var C = u.ownerDocument;
|
|
173
|
+
u != C.body && u != C.documentElement && I.overflow != "visible" && (E = T(u));
|
|
168
174
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
l != B.body && l != B.documentElement && I.overflow != "visible" && (E = T(l));
|
|
175
|
+
if (E && (s = v(E, s)), !s) break;
|
|
176
|
+
u = u && _(u);
|
|
172
177
|
}
|
|
173
|
-
|
|
174
|
-
|
|
178
|
+
return s;
|
|
179
|
+
}
|
|
180
|
+
}, a.prototype._getRootRect = function() {
|
|
181
|
+
var t;
|
|
182
|
+
if (this.root && !R(this.root))
|
|
183
|
+
t = T(this.root);
|
|
184
|
+
else {
|
|
185
|
+
var e = R(this.root) ? this.root : n, o = e.documentElement, s = e.body;
|
|
186
|
+
t = {
|
|
187
|
+
top: 0,
|
|
188
|
+
left: 0,
|
|
189
|
+
right: o.clientWidth || s.clientWidth,
|
|
190
|
+
width: o.clientWidth || s.clientWidth,
|
|
191
|
+
bottom: o.clientHeight || s.clientHeight,
|
|
192
|
+
height: o.clientHeight || s.clientHeight
|
|
193
|
+
};
|
|
175
194
|
}
|
|
176
|
-
return
|
|
195
|
+
return this._expandRectByRootMargin(t);
|
|
196
|
+
}, a.prototype._expandRectByRootMargin = function(t) {
|
|
197
|
+
var e = this._rootMarginValues.map(function(s, u) {
|
|
198
|
+
return s.unit == "px" ? s.value : s.value * (u % 2 ? t.width : t.height) / 100;
|
|
199
|
+
}), o = {
|
|
200
|
+
top: t.top - e[0],
|
|
201
|
+
right: t.right + e[1],
|
|
202
|
+
bottom: t.bottom + e[2],
|
|
203
|
+
left: t.left - e[3]
|
|
204
|
+
};
|
|
205
|
+
return o.width = o.right - o.left, o.height = o.bottom - o.top, o;
|
|
206
|
+
}, a.prototype._hasCrossedThreshold = function(t, e) {
|
|
207
|
+
var o = t && t.isIntersecting ? t.intersectionRatio || 0 : -1, s = e.isIntersecting ? e.intersectionRatio || 0 : -1;
|
|
208
|
+
if (o !== s)
|
|
209
|
+
for (var u = 0; u < this.thresholds.length; u++) {
|
|
210
|
+
var O = this.thresholds[u];
|
|
211
|
+
if (O == o || O == s || O < o != O < s)
|
|
212
|
+
return !0;
|
|
213
|
+
}
|
|
214
|
+
}, a.prototype._rootIsInDom = function() {
|
|
215
|
+
return !this.root || h(n, this.root);
|
|
216
|
+
}, a.prototype._rootContainsTarget = function(t) {
|
|
217
|
+
var e = this.root && (this.root.ownerDocument || this.root) || n;
|
|
218
|
+
return h(e, t) && (!this.root || e == t.ownerDocument);
|
|
219
|
+
}, a.prototype._registerInstance = function() {
|
|
220
|
+
i.indexOf(this) < 0 && i.push(this);
|
|
221
|
+
}, a.prototype._unregisterInstance = function() {
|
|
222
|
+
var t = i.indexOf(this);
|
|
223
|
+
t != -1 && i.splice(t, 1);
|
|
224
|
+
};
|
|
225
|
+
function m() {
|
|
226
|
+
return window.performance && performance.now && performance.now();
|
|
227
|
+
}
|
|
228
|
+
function d(t, e) {
|
|
229
|
+
var o = null;
|
|
230
|
+
return function() {
|
|
231
|
+
o || (o = setTimeout(function() {
|
|
232
|
+
t(), o = null;
|
|
233
|
+
}, e));
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
function c(t, e, o, s) {
|
|
237
|
+
typeof t.addEventListener == "function" ? t.addEventListener(e, o, s) : typeof t.attachEvent == "function" && t.attachEvent("on" + e, o);
|
|
177
238
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
239
|
+
function l(t, e, o, s) {
|
|
240
|
+
typeof t.removeEventListener == "function" ? t.removeEventListener(e, o, s) : typeof t.detatchEvent == "function" && t.detatchEvent("on" + e, o);
|
|
241
|
+
}
|
|
242
|
+
function v(t, e) {
|
|
243
|
+
var o = Math.max(t.top, e.top), s = Math.min(t.bottom, e.bottom), u = Math.max(t.left, e.left), O = Math.min(t.right, e.right), E = O - u, I = s - o;
|
|
244
|
+
return E >= 0 && I >= 0 && {
|
|
245
|
+
top: o,
|
|
246
|
+
bottom: s,
|
|
247
|
+
left: u,
|
|
248
|
+
right: O,
|
|
249
|
+
width: E,
|
|
250
|
+
height: I
|
|
251
|
+
} || null;
|
|
252
|
+
}
|
|
253
|
+
function T(t) {
|
|
254
|
+
var e;
|
|
255
|
+
try {
|
|
256
|
+
e = t.getBoundingClientRect();
|
|
257
|
+
} catch {
|
|
258
|
+
}
|
|
259
|
+
return e ? (e.width && e.height || (e = {
|
|
260
|
+
top: e.top,
|
|
261
|
+
right: e.right,
|
|
262
|
+
bottom: e.bottom,
|
|
263
|
+
left: e.left,
|
|
264
|
+
width: e.right - e.left,
|
|
265
|
+
height: e.bottom - e.top
|
|
266
|
+
}), e) : y();
|
|
267
|
+
}
|
|
268
|
+
function y() {
|
|
269
|
+
return {
|
|
185
270
|
top: 0,
|
|
271
|
+
bottom: 0,
|
|
186
272
|
left: 0,
|
|
187
|
-
right:
|
|
188
|
-
width:
|
|
189
|
-
|
|
190
|
-
height: o.clientHeight || s.clientHeight
|
|
273
|
+
right: 0,
|
|
274
|
+
width: 0,
|
|
275
|
+
height: 0
|
|
191
276
|
};
|
|
192
277
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}, a.prototype._hasCrossedThreshold = function(t, e) {
|
|
205
|
-
var o = t && t.isIntersecting ? t.intersectionRatio || 0 : -1, s = e.isIntersecting ? e.intersectionRatio || 0 : -1;
|
|
206
|
-
if (o !== s)
|
|
207
|
-
for (var l = 0; l < this.thresholds.length; l++) {
|
|
208
|
-
var O = this.thresholds[l];
|
|
209
|
-
if (O == o || O == s || O < o != O < s)
|
|
210
|
-
return !0;
|
|
211
|
-
}
|
|
212
|
-
}, a.prototype._rootIsInDom = function() {
|
|
213
|
-
return !this.root || h(n, this.root);
|
|
214
|
-
}, a.prototype._rootContainsTarget = function(t) {
|
|
215
|
-
var e = this.root && (this.root.ownerDocument || this.root) || n;
|
|
216
|
-
return h(e, t) && (!this.root || e == t.ownerDocument);
|
|
217
|
-
}, a.prototype._registerInstance = function() {
|
|
218
|
-
i.indexOf(this) < 0 && i.push(this);
|
|
219
|
-
}, a.prototype._unregisterInstance = function() {
|
|
220
|
-
var t = i.indexOf(this);
|
|
221
|
-
t != -1 && i.splice(t, 1);
|
|
222
|
-
};
|
|
223
|
-
function m() {
|
|
224
|
-
return window.performance && performance.now && performance.now();
|
|
225
|
-
}
|
|
226
|
-
function d(t, e) {
|
|
227
|
-
var o = null;
|
|
228
|
-
return function() {
|
|
229
|
-
o || (o = setTimeout(function() {
|
|
230
|
-
t(), o = null;
|
|
231
|
-
}, e));
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
function c(t, e, o, s) {
|
|
235
|
-
typeof t.addEventListener == "function" ? t.addEventListener(e, o, s) : typeof t.attachEvent == "function" && t.attachEvent("on" + e, o);
|
|
236
|
-
}
|
|
237
|
-
function u(t, e, o, s) {
|
|
238
|
-
typeof t.removeEventListener == "function" ? t.removeEventListener(e, o, s) : typeof t.detatchEvent == "function" && t.detatchEvent("on" + e, o);
|
|
239
|
-
}
|
|
240
|
-
function v(t, e) {
|
|
241
|
-
var o = Math.max(t.top, e.top), s = Math.min(t.bottom, e.bottom), l = Math.max(t.left, e.left), O = Math.min(t.right, e.right), E = O - l, I = s - o;
|
|
242
|
-
return E >= 0 && I >= 0 && {
|
|
243
|
-
top: o,
|
|
244
|
-
bottom: s,
|
|
245
|
-
left: l,
|
|
246
|
-
right: O,
|
|
247
|
-
width: E,
|
|
248
|
-
height: I
|
|
249
|
-
} || null;
|
|
250
|
-
}
|
|
251
|
-
function T(t) {
|
|
252
|
-
var e;
|
|
253
|
-
try {
|
|
254
|
-
e = t.getBoundingClientRect();
|
|
255
|
-
} catch {
|
|
278
|
+
function b(t) {
|
|
279
|
+
return !t || "x" in t ? t : {
|
|
280
|
+
top: t.top,
|
|
281
|
+
y: t.top,
|
|
282
|
+
bottom: t.bottom,
|
|
283
|
+
left: t.left,
|
|
284
|
+
x: t.left,
|
|
285
|
+
right: t.right,
|
|
286
|
+
width: t.width,
|
|
287
|
+
height: t.height
|
|
288
|
+
};
|
|
256
289
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
return {
|
|
268
|
-
top: 0,
|
|
269
|
-
bottom: 0,
|
|
270
|
-
left: 0,
|
|
271
|
-
right: 0,
|
|
272
|
-
width: 0,
|
|
273
|
-
height: 0
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
function b(t) {
|
|
277
|
-
return !t || "x" in t ? t : {
|
|
278
|
-
top: t.top,
|
|
279
|
-
y: t.top,
|
|
280
|
-
bottom: t.bottom,
|
|
281
|
-
left: t.left,
|
|
282
|
-
x: t.left,
|
|
283
|
-
right: t.right,
|
|
284
|
-
width: t.width,
|
|
285
|
-
height: t.height
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
function x(t, e) {
|
|
289
|
-
var o = e.top - t.top, s = e.left - t.left;
|
|
290
|
-
return {
|
|
291
|
-
top: o,
|
|
292
|
-
left: s,
|
|
293
|
-
height: e.height,
|
|
294
|
-
width: e.width,
|
|
295
|
-
bottom: o + e.height,
|
|
296
|
-
right: s + e.width
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
function h(t, e) {
|
|
300
|
-
for (var o = e; o; ) {
|
|
301
|
-
if (o == t) return !0;
|
|
302
|
-
o = _(o);
|
|
290
|
+
function x(t, e) {
|
|
291
|
+
var o = e.top - t.top, s = e.left - t.left;
|
|
292
|
+
return {
|
|
293
|
+
top: o,
|
|
294
|
+
left: s,
|
|
295
|
+
height: e.height,
|
|
296
|
+
width: e.width,
|
|
297
|
+
bottom: o + e.height,
|
|
298
|
+
right: s + e.width
|
|
299
|
+
};
|
|
303
300
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
return t.nodeType == /* DOCUMENT */
|
|
309
|
-
9 && t != n ? g(t) : (e && e.assignedSlot && (e = e.assignedSlot.parentNode), e && e.nodeType == 11 && e.host ? e.host : e);
|
|
310
|
-
}
|
|
311
|
-
function R(t) {
|
|
312
|
-
return t && t.nodeType === 9;
|
|
313
|
-
}
|
|
314
|
-
window.IntersectionObserver = a, window.IntersectionObserverEntry = w;
|
|
315
|
-
})();
|
|
316
|
-
var A = { exports: {} };
|
|
317
|
-
(function(g) {
|
|
318
|
-
var n = Object.prototype.hasOwnProperty, i = "~";
|
|
319
|
-
function p() {
|
|
320
|
-
}
|
|
321
|
-
Object.create && (p.prototype = /* @__PURE__ */ Object.create(null), new p().__proto__ || (i = !1));
|
|
322
|
-
function f(d, c, u) {
|
|
323
|
-
this.fn = d, this.context = c, this.once = u || !1;
|
|
324
|
-
}
|
|
325
|
-
function w(d, c, u, v, T) {
|
|
326
|
-
if (typeof u != "function")
|
|
327
|
-
throw new TypeError("The listener must be a function");
|
|
328
|
-
var y = new f(u, v || d, T), b = i ? i + c : c;
|
|
329
|
-
return d._events[b] ? d._events[b].fn ? d._events[b] = [d._events[b], y] : d._events[b].push(y) : (d._events[b] = y, d._eventsCount++), d;
|
|
330
|
-
}
|
|
331
|
-
function a(d, c) {
|
|
332
|
-
--d._eventsCount === 0 ? d._events = new p() : delete d._events[c];
|
|
333
|
-
}
|
|
334
|
-
function m() {
|
|
335
|
-
this._events = new p(), this._eventsCount = 0;
|
|
336
|
-
}
|
|
337
|
-
m.prototype.eventNames = function() {
|
|
338
|
-
var c = [], u, v;
|
|
339
|
-
if (this._eventsCount === 0) return c;
|
|
340
|
-
for (v in u = this._events)
|
|
341
|
-
n.call(u, v) && c.push(i ? v.slice(1) : v);
|
|
342
|
-
return Object.getOwnPropertySymbols ? c.concat(Object.getOwnPropertySymbols(u)) : c;
|
|
343
|
-
}, m.prototype.listeners = function(c) {
|
|
344
|
-
var u = i ? i + c : c, v = this._events[u];
|
|
345
|
-
if (!v) return [];
|
|
346
|
-
if (v.fn) return [v.fn];
|
|
347
|
-
for (var T = 0, y = v.length, b = new Array(y); T < y; T++)
|
|
348
|
-
b[T] = v[T].fn;
|
|
349
|
-
return b;
|
|
350
|
-
}, m.prototype.listenerCount = function(c) {
|
|
351
|
-
var u = i ? i + c : c, v = this._events[u];
|
|
352
|
-
return v ? v.fn ? 1 : v.length : 0;
|
|
353
|
-
}, m.prototype.emit = function(c, u, v, T, y, b) {
|
|
354
|
-
var x = i ? i + c : c;
|
|
355
|
-
if (!this._events[x]) return !1;
|
|
356
|
-
var h = this._events[x], _ = arguments.length, R, t;
|
|
357
|
-
if (h.fn) {
|
|
358
|
-
switch (h.once && this.removeListener(c, h.fn, void 0, !0), _) {
|
|
359
|
-
case 1:
|
|
360
|
-
return h.fn.call(h.context), !0;
|
|
361
|
-
case 2:
|
|
362
|
-
return h.fn.call(h.context, u), !0;
|
|
363
|
-
case 3:
|
|
364
|
-
return h.fn.call(h.context, u, v), !0;
|
|
365
|
-
case 4:
|
|
366
|
-
return h.fn.call(h.context, u, v, T), !0;
|
|
367
|
-
case 5:
|
|
368
|
-
return h.fn.call(h.context, u, v, T, y), !0;
|
|
369
|
-
case 6:
|
|
370
|
-
return h.fn.call(h.context, u, v, T, y, b), !0;
|
|
301
|
+
function h(t, e) {
|
|
302
|
+
for (var o = e; o; ) {
|
|
303
|
+
if (o == t) return !0;
|
|
304
|
+
o = _(o);
|
|
371
305
|
}
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
306
|
+
return !1;
|
|
307
|
+
}
|
|
308
|
+
function _(t) {
|
|
309
|
+
var e = t.parentNode;
|
|
310
|
+
return t.nodeType == /* DOCUMENT */
|
|
311
|
+
9 && t != n ? g(t) : (e && e.assignedSlot && (e = e.assignedSlot.parentNode), e && e.nodeType == 11 && e.host ? e.host : e);
|
|
312
|
+
}
|
|
313
|
+
function R(t) {
|
|
314
|
+
return t && t.nodeType === 9;
|
|
315
|
+
}
|
|
316
|
+
window.IntersectionObserver = a, window.IntersectionObserverEntry = w;
|
|
317
|
+
}()), A;
|
|
318
|
+
}
|
|
319
|
+
q();
|
|
320
|
+
var P = { exports: {} }, H;
|
|
321
|
+
function G() {
|
|
322
|
+
return H || (H = 1, function(g) {
|
|
323
|
+
var n = Object.prototype.hasOwnProperty, i = "~";
|
|
324
|
+
function p() {
|
|
325
|
+
}
|
|
326
|
+
Object.create && (p.prototype = /* @__PURE__ */ Object.create(null), new p().__proto__ || (i = !1));
|
|
327
|
+
function f(d, c, l) {
|
|
328
|
+
this.fn = d, this.context = c, this.once = l || !1;
|
|
329
|
+
}
|
|
330
|
+
function w(d, c, l, v, T) {
|
|
331
|
+
if (typeof l != "function")
|
|
332
|
+
throw new TypeError("The listener must be a function");
|
|
333
|
+
var y = new f(l, v || d, T), b = i ? i + c : c;
|
|
334
|
+
return d._events[b] ? d._events[b].fn ? d._events[b] = [d._events[b], y] : d._events[b].push(y) : (d._events[b] = y, d._eventsCount++), d;
|
|
335
|
+
}
|
|
336
|
+
function a(d, c) {
|
|
337
|
+
--d._eventsCount === 0 ? d._events = new p() : delete d._events[c];
|
|
338
|
+
}
|
|
339
|
+
function m() {
|
|
340
|
+
this._events = new p(), this._eventsCount = 0;
|
|
341
|
+
}
|
|
342
|
+
m.prototype.eventNames = function() {
|
|
343
|
+
var c = [], l, v;
|
|
344
|
+
if (this._eventsCount === 0) return c;
|
|
345
|
+
for (v in l = this._events)
|
|
346
|
+
n.call(l, v) && c.push(i ? v.slice(1) : v);
|
|
347
|
+
return Object.getOwnPropertySymbols ? c.concat(Object.getOwnPropertySymbols(l)) : c;
|
|
348
|
+
}, m.prototype.listeners = function(c) {
|
|
349
|
+
var l = i ? i + c : c, v = this._events[l];
|
|
350
|
+
if (!v) return [];
|
|
351
|
+
if (v.fn) return [v.fn];
|
|
352
|
+
for (var T = 0, y = v.length, b = new Array(y); T < y; T++)
|
|
353
|
+
b[T] = v[T].fn;
|
|
354
|
+
return b;
|
|
355
|
+
}, m.prototype.listenerCount = function(c) {
|
|
356
|
+
var l = i ? i + c : c, v = this._events[l];
|
|
357
|
+
return v ? v.fn ? 1 : v.length : 0;
|
|
358
|
+
}, m.prototype.emit = function(c, l, v, T, y, b) {
|
|
359
|
+
var x = i ? i + c : c;
|
|
360
|
+
if (!this._events[x]) return !1;
|
|
361
|
+
var h = this._events[x], _ = arguments.length, R, t;
|
|
362
|
+
if (h.fn) {
|
|
363
|
+
switch (h.once && this.removeListener(c, h.fn, void 0, !0), _) {
|
|
379
364
|
case 1:
|
|
380
|
-
h
|
|
381
|
-
break;
|
|
365
|
+
return h.fn.call(h.context), !0;
|
|
382
366
|
case 2:
|
|
383
|
-
h
|
|
384
|
-
break;
|
|
367
|
+
return h.fn.call(h.context, l), !0;
|
|
385
368
|
case 3:
|
|
386
|
-
h
|
|
387
|
-
break;
|
|
369
|
+
return h.fn.call(h.context, l, v), !0;
|
|
388
370
|
case 4:
|
|
389
|
-
h
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
h[t].fn.apply(h[t].context, R);
|
|
371
|
+
return h.fn.call(h.context, l, v, T), !0;
|
|
372
|
+
case 5:
|
|
373
|
+
return h.fn.call(h.context, l, v, T, y), !0;
|
|
374
|
+
case 6:
|
|
375
|
+
return h.fn.call(h.context, l, v, T, y, b), !0;
|
|
395
376
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
|
|
377
|
+
for (t = 1, R = new Array(_ - 1); t < _; t++)
|
|
378
|
+
R[t - 1] = arguments[t];
|
|
379
|
+
h.fn.apply(h.context, R);
|
|
380
|
+
} else {
|
|
381
|
+
var e = h.length, o;
|
|
382
|
+
for (t = 0; t < e; t++)
|
|
383
|
+
switch (h[t].once && this.removeListener(c, h[t].fn, void 0, !0), _) {
|
|
384
|
+
case 1:
|
|
385
|
+
h[t].fn.call(h[t].context);
|
|
386
|
+
break;
|
|
387
|
+
case 2:
|
|
388
|
+
h[t].fn.call(h[t].context, l);
|
|
389
|
+
break;
|
|
390
|
+
case 3:
|
|
391
|
+
h[t].fn.call(h[t].context, l, v);
|
|
392
|
+
break;
|
|
393
|
+
case 4:
|
|
394
|
+
h[t].fn.call(h[t].context, l, v, T);
|
|
395
|
+
break;
|
|
396
|
+
default:
|
|
397
|
+
if (!R) for (o = 1, R = new Array(_ - 1); o < _; o++)
|
|
398
|
+
R[o - 1] = arguments[o];
|
|
399
|
+
h[t].fn.apply(h[t].context, R);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
return !0;
|
|
403
|
+
}, m.prototype.on = function(c, l, v) {
|
|
404
|
+
return w(this, c, l, v, !1);
|
|
405
|
+
}, m.prototype.once = function(c, l, v) {
|
|
406
|
+
return w(this, c, l, v, !0);
|
|
407
|
+
}, m.prototype.removeListener = function(c, l, v, T) {
|
|
408
|
+
var y = i ? i + c : c;
|
|
409
|
+
if (!this._events[y]) return this;
|
|
410
|
+
if (!l)
|
|
411
|
+
return a(this, y), this;
|
|
412
|
+
var b = this._events[y];
|
|
413
|
+
if (b.fn)
|
|
414
|
+
b.fn === l && (!T || b.once) && (!v || b.context === v) && a(this, y);
|
|
415
|
+
else {
|
|
416
|
+
for (var x = 0, h = [], _ = b.length; x < _; x++)
|
|
417
|
+
(b[x].fn !== l || T && !b[x].once || v && b[x].context !== v) && h.push(b[x]);
|
|
418
|
+
h.length ? this._events[y] = h.length === 1 ? h[0] : h : a(this, y);
|
|
419
|
+
}
|
|
420
|
+
return this;
|
|
421
|
+
}, m.prototype.removeAllListeners = function(c) {
|
|
422
|
+
var l;
|
|
423
|
+
return c ? (l = i ? i + c : c, this._events[l] && a(this, l)) : (this._events = new p(), this._eventsCount = 0), this;
|
|
424
|
+
}, m.prototype.off = m.prototype.removeListener, m.prototype.addListener = m.prototype.on, m.prefixed = i, m.EventEmitter = m, g.exports = m;
|
|
425
|
+
}(P)), P.exports;
|
|
426
|
+
}
|
|
427
|
+
var z = G(), W = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, Y = (g, n, i, p) => {
|
|
428
|
+
for (var f = $(n, i), w = g.length - 1, a; w >= 0; w--)
|
|
423
429
|
(a = g[w]) && (f = a(n, i, f) || f);
|
|
424
|
-
return f &&
|
|
430
|
+
return f && W(n, i, f), f;
|
|
425
431
|
};
|
|
426
432
|
const k = 60;
|
|
427
433
|
var r;
|
|
428
|
-
const
|
|
434
|
+
const N = (r = class {
|
|
429
435
|
static on(n, i) {
|
|
430
436
|
r.events.on(n, i);
|
|
431
437
|
}
|
|
@@ -461,7 +467,7 @@ const F = (r = class {
|
|
|
461
467
|
/** PositioningService will start controlling the position of the given element. */
|
|
462
468
|
static position(n, i = {}) {
|
|
463
469
|
const p = {
|
|
464
|
-
...
|
|
470
|
+
...V,
|
|
465
471
|
...i
|
|
466
472
|
};
|
|
467
473
|
let f = n;
|
|
@@ -474,7 +480,7 @@ const F = (r = class {
|
|
|
474
480
|
throw new Error(
|
|
475
481
|
"You must provide an element for the relativeTo option to position an element."
|
|
476
482
|
);
|
|
477
|
-
r.elements.set(n, p),
|
|
483
|
+
r.elements.set(n, p), U(() => {
|
|
478
484
|
r.fixElementPosition(n), r.viewportObserver.observe(n), n.style.visibility = "", r.checkCollisions(n);
|
|
479
485
|
});
|
|
480
486
|
}
|
|
@@ -555,8 +561,8 @@ const F = (r = class {
|
|
|
555
561
|
zIndex: p.zIndex || ""
|
|
556
562
|
});
|
|
557
563
|
let d, c;
|
|
558
|
-
const
|
|
559
|
-
switch (d = 0, c = 0,
|
|
564
|
+
const l = p.position.split(" "), v = p.offsets[0] || 0, T = p.offsets[1] || 0;
|
|
565
|
+
switch (d = 0, c = 0, l[0]) {
|
|
560
566
|
case "top":
|
|
561
567
|
d = a.top - w.height - v;
|
|
562
568
|
break;
|
|
@@ -572,7 +578,7 @@ const F = (r = class {
|
|
|
572
578
|
default:
|
|
573
579
|
throw new Error(`${p.position} is not a valid position`);
|
|
574
580
|
}
|
|
575
|
-
switch (
|
|
581
|
+
switch (l[1]) {
|
|
576
582
|
case "left":
|
|
577
583
|
c = a.left - T;
|
|
578
584
|
break;
|
|
@@ -580,7 +586,7 @@ const F = (r = class {
|
|
|
580
586
|
d = a.top - T;
|
|
581
587
|
break;
|
|
582
588
|
case "middle":
|
|
583
|
-
|
|
589
|
+
l[0] === "top" || l[0] === "bottom" ? c = a.left + a.width / 2 - m / 2 + T : (l[0] === "left" || l[0] === "right") && (d = a.top + a.height / 2 - w.height / 2 + T);
|
|
584
590
|
break;
|
|
585
591
|
case "bottom":
|
|
586
592
|
d = a.bottom - w.height + T;
|
|
@@ -666,20 +672,20 @@ const F = (r = class {
|
|
|
666
672
|
reposition(n, i) {
|
|
667
673
|
r.reposition(n, i);
|
|
668
674
|
}
|
|
669
|
-
}, r.elements = /* @__PURE__ */ new Map(), r.registeredScrollParents = /* @__PURE__ */ new Set(), r.events = new
|
|
675
|
+
}, r.elements = /* @__PURE__ */ new Map(), r.registeredScrollParents = /* @__PURE__ */ new Set(), r.events = new z.EventEmitter(), r.viewportObserver = new IntersectionObserver(
|
|
670
676
|
r.onViewportIntersection,
|
|
671
677
|
{
|
|
672
678
|
rootMargin: `-${k}px 0px 0px`,
|
|
673
679
|
threshold: 1
|
|
674
680
|
}
|
|
675
681
|
), r);
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
],
|
|
679
|
-
let
|
|
682
|
+
Y([
|
|
683
|
+
j
|
|
684
|
+
], N, "update");
|
|
685
|
+
let K = N;
|
|
680
686
|
export {
|
|
681
|
-
|
|
682
|
-
|
|
687
|
+
V as DEFAULT_POSITIONING_OPTIONS,
|
|
688
|
+
S as Position,
|
|
683
689
|
M as PositionAnchor,
|
|
684
|
-
|
|
690
|
+
K as PositioningService
|
|
685
691
|
};
|
package/lib/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(D,k){typeof exports=="object"&&typeof module<"u"?k(exports,require("@spscommerce/utils")):typeof define=="function"&&define.amd?define(["exports","@spscommerce/utils"],k):(D=typeof globalThis<"u"?globalThis:D||self,k(D.Positioning={},D.utils))})(this,function(D,k){"use strict";var r;var A=(g=>(g.TOP_LEFT="top left",g.TOP_MIDDLE="top middle",g.TOP_RIGHT="top right",g.RIGHT_TOP="right top",g.RIGHT_MIDDLE="right middle",g.RIGHT_BOTTOM="right bottom",g.BOTTOM_RIGHT="bottom right",g.BOTTOM_MIDDLE="bottom middle",g.BOTTOM_LEFT="bottom left",g.LEFT_BOTTOM="left bottom",g.LEFT_MIDDLE="left middle",g.LEFT_TOP="left top",g))(A||{}),P=(g=>(g.TOP_LEFT="top left",g.TOP_RIGHT="top right",g.BOTTOM_LEFT="bottom left",g.BOTTOM_RIGHT="bottom right",g))(P||{});const C={anchor:P.TOP_LEFT,offsets:[],position:A.TOP_LEFT};(function(){if(typeof window!="object")return;if("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype){"isIntersecting"in window.IntersectionObserverEntry.prototype||Object.defineProperty(window.IntersectionObserverEntry.prototype,"isIntersecting",{get:function(){return this.intersectionRatio>0}});return}function g(t){try{return t.defaultView&&t.defaultView.frameElement||null}catch{return null}}var n=function(t){for(var e=t,o=g(e);o;)e=o.ownerDocument,o=g(e);return e}(window.document),i=[],p=null,f=null;function w(t){this.time=t.time,this.target=t.target,this.rootBounds=b(t.rootBounds),this.boundingClientRect=b(t.boundingClientRect),this.intersectionRect=b(t.intersectionRect||y()),this.isIntersecting=!!t.intersectionRect;var e=this.boundingClientRect,o=e.width*e.height,s=this.intersectionRect,u=s.width*s.height;o?this.intersectionRatio=Number((u/o).toFixed(4)):this.intersectionRatio=this.isIntersecting?1:0}function a(t,e){var o=e||{};if(typeof t!="function")throw new Error("callback must be a function");if(o.root&&o.root.nodeType!=1&&o.root.nodeType!=9)throw new Error("root must be a Document or Element");this._checkForIntersections=v(this._checkForIntersections.bind(this),this.THROTTLE_TIMEOUT),this._callback=t,this._observationTargets=[],this._queuedEntries=[],this._rootMarginValues=this._parseRootMargin(o.rootMargin),this.thresholds=this._initThresholds(o.threshold),this.root=o.root||null,this.rootMargin=this._rootMarginValues.map(function(s){return s.value+s.unit}).join(" "),this._monitoringDocuments=[],this._monitoringUnsubscribes=[]}a.prototype.THROTTLE_TIMEOUT=100,a.prototype.POLL_INTERVAL=null,a.prototype.USE_MUTATION_OBSERVER=!0,a._setupCrossOriginUpdater=function(){return p||(p=function(t,e){!t||!e?f=y():f=x(t,e),i.forEach(function(o){o._checkForIntersections()})}),p},a._resetCrossOriginUpdater=function(){p=null,f=null},a.prototype.observe=function(t){var e=this._observationTargets.some(function(o){return o.element==t});if(!e){if(!(t&&t.nodeType==1))throw new Error("target must be an Element");this._registerInstance(),this._observationTargets.push({element:t,entry:null}),this._monitorIntersections(t.ownerDocument),this._checkForIntersections()}},a.prototype.unobserve=function(t){this._observationTargets=this._observationTargets.filter(function(e){return e.element!=t}),this._unmonitorIntersections(t.ownerDocument),this._observationTargets.length==0&&this._unregisterInstance()},a.prototype.disconnect=function(){this._observationTargets=[],this._unmonitorAllIntersections(),this._unregisterInstance()},a.prototype.takeRecords=function(){var t=this._queuedEntries.slice();return this._queuedEntries=[],t},a.prototype._initThresholds=function(t){var e=t||[0];return Array.isArray(e)||(e=[e]),e.sort().filter(function(o,s,u){if(typeof o!="number"||isNaN(o)||o<0||o>1)throw new Error("threshold must be a number between 0 and 1 inclusively");return o!==u[s-1]})},a.prototype._parseRootMargin=function(t){var e=t||"0px",o=e.split(/\s+/).map(function(s){var u=/^(-?\d*\.?\d+)(px|%)$/.exec(s);if(!u)throw new Error("rootMargin must be specified in pixels or percent");return{value:parseFloat(u[1]),unit:u[2]}});return o[1]=o[1]||o[0],o[2]=o[2]||o[0],o[3]=o[3]||o[1],o},a.prototype._monitorIntersections=function(t){var e=t.defaultView;if(e&&this._monitoringDocuments.indexOf(t)==-1){var o=this._checkForIntersections,s=null,u=null;this.POLL_INTERVAL?s=e.setInterval(o,this.POLL_INTERVAL):(c(e,"resize",o,!0),c(t,"scroll",o,!0),this.USE_MUTATION_OBSERVER&&"MutationObserver"in e&&(u=new e.MutationObserver(o),u.observe(t,{attributes:!0,childList:!0,characterData:!0,subtree:!0}))),this._monitoringDocuments.push(t),this._monitoringUnsubscribes.push(function(){var I=t.defaultView;I&&(s&&I.clearInterval(s),l(I,"resize",o,!0)),l(t,"scroll",o,!0),u&&u.disconnect()});var O=this.root&&(this.root.ownerDocument||this.root)||n;if(t!=O){var E=g(t);E&&this._monitorIntersections(E.ownerDocument)}}},a.prototype._unmonitorIntersections=function(t){var e=this._monitoringDocuments.indexOf(t);if(e!=-1){var o=this.root&&(this.root.ownerDocument||this.root)||n,s=this._observationTargets.some(function(E){var I=E.element.ownerDocument;if(I==t)return!0;for(;I&&I!=o;){var L=g(I);if(I=L&&L.ownerDocument,I==t)return!0}return!1});if(!s){var u=this._monitoringUnsubscribes[e];if(this._monitoringDocuments.splice(e,1),this._monitoringUnsubscribes.splice(e,1),u(),t!=o){var O=g(t);O&&this._unmonitorIntersections(O.ownerDocument)}}}},a.prototype._unmonitorAllIntersections=function(){var t=this._monitoringUnsubscribes.slice(0);this._monitoringDocuments.length=0,this._monitoringUnsubscribes.length=0;for(var e=0;e<t.length;e++)t[e]()},a.prototype._checkForIntersections=function(){if(!(!this.root&&p&&!f)){var t=this._rootIsInDom(),e=t?this._getRootRect():y();this._observationTargets.forEach(function(o){var s=o.element,u=T(s),O=this._rootContainsTarget(s),E=o.entry,I=t&&O&&this._computeTargetAndRootIntersection(s,u,e),L=null;this._rootContainsTarget(s)?(!p||this.root)&&(L=e):L=y();var M=o.entry=new w({time:m(),target:s,boundingClientRect:u,rootBounds:L,intersectionRect:I});E?t&&O?this._hasCrossedThreshold(E,M)&&this._queuedEntries.push(M):E&&E.isIntersecting&&this._queuedEntries.push(M):this._queuedEntries.push(M)},this),this._queuedEntries.length&&this._callback(this.takeRecords(),this)}},a.prototype._computeTargetAndRootIntersection=function(t,e,o){if(window.getComputedStyle(t).display!="none"){for(var s=e,u=_(t),O=!1;!O&&u;){var E=null,I=u.nodeType==1?window.getComputedStyle(u):{};if(I.display=="none")return null;if(u==this.root||u.nodeType==9)if(O=!0,u==this.root||u==n)p&&!this.root?!f||f.width==0&&f.height==0?(u=null,E=null,s=null):E=f:E=o;else{var L=_(u),M=L&&T(L),N=L&&this._computeTargetAndRootIntersection(L,M,o);M&&N?(u=L,E=x(M,N)):(u=null,s=null)}else{var H=u.ownerDocument;u!=H.body&&u!=H.documentElement&&I.overflow!="visible"&&(E=T(u))}if(E&&(s=d(E,s)),!s)break;u=u&&_(u)}return s}},a.prototype._getRootRect=function(){var t;if(this.root&&!R(this.root))t=T(this.root);else{var e=R(this.root)?this.root:n,o=e.documentElement,s=e.body;t={top:0,left:0,right:o.clientWidth||s.clientWidth,width:o.clientWidth||s.clientWidth,bottom:o.clientHeight||s.clientHeight,height:o.clientHeight||s.clientHeight}}return this._expandRectByRootMargin(t)},a.prototype._expandRectByRootMargin=function(t){var e=this._rootMarginValues.map(function(s,u){return s.unit=="px"?s.value:s.value*(u%2?t.width:t.height)/100}),o={top:t.top-e[0],right:t.right+e[1],bottom:t.bottom+e[2],left:t.left-e[3]};return o.width=o.right-o.left,o.height=o.bottom-o.top,o},a.prototype._hasCrossedThreshold=function(t,e){var o=t&&t.isIntersecting?t.intersectionRatio||0:-1,s=e.isIntersecting?e.intersectionRatio||0:-1;if(o!==s)for(var u=0;u<this.thresholds.length;u++){var O=this.thresholds[u];if(O==o||O==s||O<o!=O<s)return!0}},a.prototype._rootIsInDom=function(){return!this.root||h(n,this.root)},a.prototype._rootContainsTarget=function(t){var e=this.root&&(this.root.ownerDocument||this.root)||n;return h(e,t)&&(!this.root||e==t.ownerDocument)},a.prototype._registerInstance=function(){i.indexOf(this)<0&&i.push(this)},a.prototype._unregisterInstance=function(){var t=i.indexOf(this);t!=-1&&i.splice(t,1)};function m(){return window.performance&&performance.now&&performance.now()}function v(t,e){var o=null;return function(){o||(o=setTimeout(function(){t(),o=null},e))}}function c(t,e,o,s){typeof t.addEventListener=="function"?t.addEventListener(e,o,s):typeof t.attachEvent=="function"&&t.attachEvent("on"+e,o)}function l(t,e,o,s){typeof t.removeEventListener=="function"?t.removeEventListener(e,o,s):typeof t.detatchEvent=="function"&&t.detatchEvent("on"+e,o)}function d(t,e){var o=Math.max(t.top,e.top),s=Math.min(t.bottom,e.bottom),u=Math.max(t.left,e.left),O=Math.min(t.right,e.right),E=O-u,I=s-o;return E>=0&&I>=0&&{top:o,bottom:s,left:u,right:O,width:E,height:I}||null}function T(t){var e;try{e=t.getBoundingClientRect()}catch{}return e?(e.width&&e.height||(e={top:e.top,right:e.right,bottom:e.bottom,left:e.left,width:e.right-e.left,height:e.bottom-e.top}),e):y()}function y(){return{top:0,bottom:0,left:0,right:0,width:0,height:0}}function b(t){return!t||"x"in t?t:{top:t.top,y:t.top,bottom:t.bottom,left:t.left,x:t.left,right:t.right,width:t.width,height:t.height}}function x(t,e){var o=e.top-t.top,s=e.left-t.left;return{top:o,left:s,height:e.height,width:e.width,bottom:o+e.height,right:s+e.width}}function h(t,e){for(var o=e;o;){if(o==t)return!0;o=_(o)}return!1}function _(t){var e=t.parentNode;return t.nodeType==9&&t!=n?g(t):(e&&e.assignedSlot&&(e=e.assignedSlot.parentNode),e&&e.nodeType==11&&e.host?e.host:e)}function R(t){return t&&t.nodeType===9}window.IntersectionObserver=a,window.IntersectionObserverEntry=w})();var F={exports:{}};(function(g){var n=Object.prototype.hasOwnProperty,i="~";function p(){}Object.create&&(p.prototype=Object.create(null),new p().__proto__||(i=!1));function f(v,c,l){this.fn=v,this.context=c,this.once=l||!1}function w(v,c,l,d,T){if(typeof l!="function")throw new TypeError("The listener must be a function");var y=new f(l,d||v,T),b=i?i+c:c;return v._events[b]?v._events[b].fn?v._events[b]=[v._events[b],y]:v._events[b].push(y):(v._events[b]=y,v._eventsCount++),v}function a(v,c){--v._eventsCount===0?v._events=new p:delete v._events[c]}function m(){this._events=new p,this._eventsCount=0}m.prototype.eventNames=function(){var c=[],l,d;if(this._eventsCount===0)return c;for(d in l=this._events)n.call(l,d)&&c.push(i?d.slice(1):d);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(l)):c},m.prototype.listeners=function(c){var l=i?i+c:c,d=this._events[l];if(!d)return[];if(d.fn)return[d.fn];for(var T=0,y=d.length,b=new Array(y);T<y;T++)b[T]=d[T].fn;return b},m.prototype.listenerCount=function(c){var l=i?i+c:c,d=this._events[l];return d?d.fn?1:d.length:0},m.prototype.emit=function(c,l,d,T,y,b){var x=i?i+c:c;if(!this._events[x])return!1;var h=this._events[x],_=arguments.length,R,t;if(h.fn){switch(h.once&&this.removeListener(c,h.fn,void 0,!0),_){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,l),!0;case 3:return h.fn.call(h.context,l,d),!0;case 4:return h.fn.call(h.context,l,d,T),!0;case 5:return h.fn.call(h.context,l,d,T,y),!0;case 6:return h.fn.call(h.context,l,d,T,y,b),!0}for(t=1,R=new Array(_-1);t<_;t++)R[t-1]=arguments[t];h.fn.apply(h.context,R)}else{var e=h.length,o;for(t=0;t<e;t++)switch(h[t].once&&this.removeListener(c,h[t].fn,void 0,!0),_){case 1:h[t].fn.call(h[t].context);break;case 2:h[t].fn.call(h[t].context,l);break;case 3:h[t].fn.call(h[t].context,l,d);break;case 4:h[t].fn.call(h[t].context,l,d,T);break;default:if(!R)for(o=1,R=new Array(_-1);o<_;o++)R[o-1]=arguments[o];h[t].fn.apply(h[t].context,R)}}return!0},m.prototype.on=function(c,l,d){return w(this,c,l,d,!1)},m.prototype.once=function(c,l,d){return w(this,c,l,d,!0)},m.prototype.removeListener=function(c,l,d,T){var y=i?i+c:c;if(!this._events[y])return this;if(!l)return a(this,y),this;var b=this._events[y];if(b.fn)b.fn===l&&(!T||b.once)&&(!d||b.context===d)&&a(this,y);else{for(var x=0,h=[],_=b.length;x<_;x++)(b[x].fn!==l||T&&!b[x].once||d&&b[x].context!==d)&&h.push(b[x]);h.length?this._events[y]=h.length===1?h[0]:h:a(this,y)}return this},m.prototype.removeAllListeners=function(c){var l;return c?(l=i?i+c:c,this._events[l]&&a(this,l)):(this._events=new p,this._eventsCount=0),this},m.prototype.off=m.prototype.removeListener,m.prototype.addListener=m.prototype.on,m.prefixed=i,m.EventEmitter=m,g.exports=m})(F);var j=F.exports,U=Object.defineProperty,V=Object.getOwnPropertyDescriptor,G=(g,n,i,p)=>{for(var f=V(n,i),w=g.length-1,a;w>=0;w--)(a=g[w])&&(f=a(n,i,f)||f);return f&&U(n,i,f),f};const B=60,S=(r=class{static on(n,i){r.events.on(n,i)}static off(n,i){r.events.off(n,i)}static once(n,i){r.events.once(n,i)}static checkCollisions(n,i){const p=i||Array.from(r.elements.keys()),f=n.getBoundingClientRect(),w=[];for(const a of p)if(a!==n){const m=a.getBoundingClientRect();m.left<=f.right&&m.right>=f.left&&m.top<=f.bottom&&m.bottom>=f.top&&w.push(a)}w.length&&r.onElementIntersection(n,w)}static isPositioned(n){return r.elements.has(n)}static getPositioningOptions(n){return r.elements.has(n)?r.elements.get(n):null}static position(n,i={}){const p={...C,...i};let f=n;for(;f!==document.body;)if(f=f.parentElement,f.classList.contains("sps-focused-task")){p.scrollParent=f,r.registeredScrollParents.has(f)||(r.registeredScrollParents.add(f),f.addEventListener("scroll",r.update));break}if(n.style.visibility="hidden",r.elements.size===0&&(window.addEventListener("resize",r.update),window.addEventListener("scroll",r.update)),!p.relativeTo)throw new Error("You must provide an element for the relativeTo option to position an element.");r.elements.set(n,p),k.onNextTick(()=>{r.fixElementPosition(n),r.viewportObserver.observe(n),n.style.visibility="",r.checkCollisions(n)})}static release(n){if(r.elements.has(n)){r.clearStyles(n);const i=r.elements.get(n);i.scrollParent&&(i.scrollParent.removeEventListener("scroll",r.update),r.registeredScrollParents.delete(i.scrollParent)),r.elements.delete(n),r.elements.size===0&&(window.removeEventListener("resize",r.update),window.removeEventListener("scroll",r.update)),r.viewportObserver.unobserve(n)}}static releaseAll(){for(const n of r.elements.keys())r.release(n)}static refresh(n){r.elements.has(n)&&(r.clearStyles(n),r.fixElementPosition(n),r.checkCollisions(n))}static refreshAll(){for(const n of r.elements.keys())r.refresh(n)}static reposition(n,i){if(r.elements.has(n)){const p=r.elements.get(n);r.elements.set(n,Object.assign(p,i)),r.refresh(n)}}static onViewportIntersection(n){for(const i of n){const p=Object.keys(IntersectionObserverEntry.prototype).reduce((f,w)=>({...f,[w]:i[w]}),{});p.rootBounds=p.rootBounds||r.getRootBounds(),r.events.emit("viewportIntersection",Object.freeze(p))}}static onElementIntersection(n,i){r.events.emit("elementIntersection",{target:n,intersectingWith:i})}static getRootBounds(){const n=Math.max(document.documentElement.clientWidth,window.innerWidth||0),i=Math.max(document.documentElement.clientHeight,window.innerHeight||0);return{x:0,y:B,left:0,top:B,right:n,bottom:i,height:i-B,width:n}}static clearStyles(n){Object.assign(n.style,{position:"",width:"",top:"",left:"",right:"",bottom:"",visibility:"",zIndex:""})}static fixElementPosition(n,i){if(!this.elements.has(n))return;const p=i||this.elements.get(n),f=this.getRootBounds(),w=n.getBoundingClientRect(),a=p.relativeTo.getBoundingClientRect(),{width:m}=p.useRelativeTargetWidth?a:w;Object.assign(n.style,{minWidth:`${m}px`,position:"fixed",zIndex:p.zIndex||""});let v,c;const l=p.position.split(" "),d=p.offsets[0]||0,T=p.offsets[1]||0;switch(v=0,c=0,l[0]){case"top":v=a.top-w.height-d;break;case"left":c=a.left-m-d;break;case"right":c=a.right+d;break;case"bottom":v=a.bottom+d;break;default:throw new Error(`${p.position} is not a valid position`)}switch(l[1]){case"left":c=a.left-T;break;case"top":v=a.top-T;break;case"middle":l[0]==="top"||l[0]==="bottom"?c=a.left+a.width/2-m/2+T:(l[0]==="left"||l[0]==="right")&&(v=a.top+a.height/2-w.height/2+T);break;case"bottom":v=a.bottom-w.height+T;break;case"right":c=a.right-m+T;break;default:throw new Error(`${p.position} is not a valid position`)}const y=v+w.height,b=c+w.width,x=`${Math.round(v)}px`,h=`${Math.round(f.bottom-y)}px`,_=`${Math.round(c)}px`,R=`${Math.round(f.right-b)}px`;switch(p.anchor){case P.TOP_LEFT:Object.assign(n.style,{top:x,bottom:"auto",left:_,right:"auto"});break;case P.TOP_RIGHT:Object.assign(n.style,{top:x,bottom:"auto",left:"auto",right:R});break;case P.BOTTOM_LEFT:Object.assign(n.style,{top:"auto",bottom:h,left:_,right:"auto"});break;case P.BOTTOM_RIGHT:Object.assign(n.style,{top:"auto",bottom:h,left:"auto",right:R});break}}static update(n){const i=r.elements.entries(),p=[];for(const[f,w]of i)(!n||n.target===document||n.target===w.scrollParent||n.target===window)&&(r.fixElementPosition(f,w),r.checkCollisions(f,p),p.push(f))}on(n,i){r.on(n,i)}off(n,i){r.off(n,i)}once(n,i){r.once(n,i)}isPositioned(n){return r.isPositioned(n)}getPositioningOptions(n){return r.getPositioningOptions(n)}position(n,i={}){r.position(n,i)}release(n){r.release(n)}releaseAll(){r.releaseAll()}refresh(n){r.refresh(n)}refreshAll(){r.refreshAll()}reposition(n,i){r.reposition(n,i)}},r.elements=new Map,r.registeredScrollParents=new Set,r.events=new j.EventEmitter,r.viewportObserver=new IntersectionObserver(r.onViewportIntersection,{rootMargin:`-${B}px 0px 0px`,threshold:1}),r);G([k.lockedToAnimationFrames],S,"update");let z=S;D.DEFAULT_POSITIONING_OPTIONS=C,D.Position=A,D.PositionAnchor=P,D.PositioningService=z,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(D,k){typeof exports=="object"&&typeof module<"u"?k(exports,require("@spscommerce/utils")):typeof define=="function"&&define.amd?define(["exports","@spscommerce/utils"],k):(D=typeof globalThis<"u"?globalThis:D||self,k(D.Positioning={},D.utils))})(this,function(D,k){"use strict";var r;var A=(g=>(g.TOP_LEFT="top left",g.TOP_MIDDLE="top middle",g.TOP_RIGHT="top right",g.RIGHT_TOP="right top",g.RIGHT_MIDDLE="right middle",g.RIGHT_BOTTOM="right bottom",g.BOTTOM_RIGHT="bottom right",g.BOTTOM_MIDDLE="bottom middle",g.BOTTOM_LEFT="bottom left",g.LEFT_BOTTOM="left bottom",g.LEFT_MIDDLE="left middle",g.LEFT_TOP="left top",g))(A||{}),P=(g=>(g.TOP_LEFT="top left",g.TOP_RIGHT="top right",g.BOTTOM_LEFT="bottom left",g.BOTTOM_RIGHT="bottom right",g))(P||{});const F={anchor:P.TOP_LEFT,offsets:[],position:A.TOP_LEFT};var S={},N;function q(){return N||(N=1,function(){if(typeof window!="object")return;if("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype){"isIntersecting"in window.IntersectionObserverEntry.prototype||Object.defineProperty(window.IntersectionObserverEntry.prototype,"isIntersecting",{get:function(){return this.intersectionRatio>0}});return}function g(t){try{return t.defaultView&&t.defaultView.frameElement||null}catch{return null}}var n=function(t){for(var e=t,o=g(e);o;)e=o.ownerDocument,o=g(e);return e}(window.document),i=[],p=null,f=null;function w(t){this.time=t.time,this.target=t.target,this.rootBounds=b(t.rootBounds),this.boundingClientRect=b(t.boundingClientRect),this.intersectionRect=b(t.intersectionRect||y()),this.isIntersecting=!!t.intersectionRect;var e=this.boundingClientRect,o=e.width*e.height,s=this.intersectionRect,u=s.width*s.height;o?this.intersectionRatio=Number((u/o).toFixed(4)):this.intersectionRatio=this.isIntersecting?1:0}function a(t,e){var o=e||{};if(typeof t!="function")throw new Error("callback must be a function");if(o.root&&o.root.nodeType!=1&&o.root.nodeType!=9)throw new Error("root must be a Document or Element");this._checkForIntersections=d(this._checkForIntersections.bind(this),this.THROTTLE_TIMEOUT),this._callback=t,this._observationTargets=[],this._queuedEntries=[],this._rootMarginValues=this._parseRootMargin(o.rootMargin),this.thresholds=this._initThresholds(o.threshold),this.root=o.root||null,this.rootMargin=this._rootMarginValues.map(function(s){return s.value+s.unit}).join(" "),this._monitoringDocuments=[],this._monitoringUnsubscribes=[]}a.prototype.THROTTLE_TIMEOUT=100,a.prototype.POLL_INTERVAL=null,a.prototype.USE_MUTATION_OBSERVER=!0,a._setupCrossOriginUpdater=function(){return p||(p=function(t,e){!t||!e?f=y():f=R(t,e),i.forEach(function(o){o._checkForIntersections()})}),p},a._resetCrossOriginUpdater=function(){p=null,f=null},a.prototype.observe=function(t){var e=this._observationTargets.some(function(o){return o.element==t});if(!e){if(!(t&&t.nodeType==1))throw new Error("target must be an Element");this._registerInstance(),this._observationTargets.push({element:t,entry:null}),this._monitorIntersections(t.ownerDocument),this._checkForIntersections()}},a.prototype.unobserve=function(t){this._observationTargets=this._observationTargets.filter(function(e){return e.element!=t}),this._unmonitorIntersections(t.ownerDocument),this._observationTargets.length==0&&this._unregisterInstance()},a.prototype.disconnect=function(){this._observationTargets=[],this._unmonitorAllIntersections(),this._unregisterInstance()},a.prototype.takeRecords=function(){var t=this._queuedEntries.slice();return this._queuedEntries=[],t},a.prototype._initThresholds=function(t){var e=t||[0];return Array.isArray(e)||(e=[e]),e.sort().filter(function(o,s,u){if(typeof o!="number"||isNaN(o)||o<0||o>1)throw new Error("threshold must be a number between 0 and 1 inclusively");return o!==u[s-1]})},a.prototype._parseRootMargin=function(t){var e=t||"0px",o=e.split(/\s+/).map(function(s){var u=/^(-?\d*\.?\d+)(px|%)$/.exec(s);if(!u)throw new Error("rootMargin must be specified in pixels or percent");return{value:parseFloat(u[1]),unit:u[2]}});return o[1]=o[1]||o[0],o[2]=o[2]||o[0],o[3]=o[3]||o[1],o},a.prototype._monitorIntersections=function(t){var e=t.defaultView;if(e&&this._monitoringDocuments.indexOf(t)==-1){var o=this._checkForIntersections,s=null,u=null;this.POLL_INTERVAL?s=e.setInterval(o,this.POLL_INTERVAL):(c(e,"resize",o,!0),c(t,"scroll",o,!0),this.USE_MUTATION_OBSERVER&&"MutationObserver"in e&&(u=new e.MutationObserver(o),u.observe(t,{attributes:!0,childList:!0,characterData:!0,subtree:!0}))),this._monitoringDocuments.push(t),this._monitoringUnsubscribes.push(function(){var I=t.defaultView;I&&(s&&I.clearInterval(s),l(I,"resize",o,!0)),l(t,"scroll",o,!0),u&&u.disconnect()});var O=this.root&&(this.root.ownerDocument||this.root)||n;if(t!=O){var E=g(t);E&&this._monitorIntersections(E.ownerDocument)}}},a.prototype._unmonitorIntersections=function(t){var e=this._monitoringDocuments.indexOf(t);if(e!=-1){var o=this.root&&(this.root.ownerDocument||this.root)||n,s=this._observationTargets.some(function(E){var I=E.element.ownerDocument;if(I==t)return!0;for(;I&&I!=o;){var L=g(I);if(I=L&&L.ownerDocument,I==t)return!0}return!1});if(!s){var u=this._monitoringUnsubscribes[e];if(this._monitoringDocuments.splice(e,1),this._monitoringUnsubscribes.splice(e,1),u(),t!=o){var O=g(t);O&&this._unmonitorIntersections(O.ownerDocument)}}}},a.prototype._unmonitorAllIntersections=function(){var t=this._monitoringUnsubscribes.slice(0);this._monitoringDocuments.length=0,this._monitoringUnsubscribes.length=0;for(var e=0;e<t.length;e++)t[e]()},a.prototype._checkForIntersections=function(){if(!(!this.root&&p&&!f)){var t=this._rootIsInDom(),e=t?this._getRootRect():y();this._observationTargets.forEach(function(o){var s=o.element,u=T(s),O=this._rootContainsTarget(s),E=o.entry,I=t&&O&&this._computeTargetAndRootIntersection(s,u,e),L=null;this._rootContainsTarget(s)?(!p||this.root)&&(L=e):L=y();var M=o.entry=new w({time:m(),target:s,boundingClientRect:u,rootBounds:L,intersectionRect:I});E?t&&O?this._hasCrossedThreshold(E,M)&&this._queuedEntries.push(M):E&&E.isIntersecting&&this._queuedEntries.push(M):this._queuedEntries.push(M)},this),this._queuedEntries.length&&this._callback(this.takeRecords(),this)}},a.prototype._computeTargetAndRootIntersection=function(t,e,o){if(window.getComputedStyle(t).display!="none"){for(var s=e,u=_(t),O=!1;!O&&u;){var E=null,I=u.nodeType==1?window.getComputedStyle(u):{};if(I.display=="none")return null;if(u==this.root||u.nodeType==9)if(O=!0,u==this.root||u==n)p&&!this.root?!f||f.width==0&&f.height==0?(u=null,E=null,s=null):E=f:E=o;else{var L=_(u),M=L&&T(L),U=L&&this._computeTargetAndRootIntersection(L,M,o);M&&U?(u=L,E=R(M,U)):(u=null,s=null)}else{var V=u.ownerDocument;u!=V.body&&u!=V.documentElement&&I.overflow!="visible"&&(E=T(u))}if(E&&(s=v(E,s)),!s)break;u=u&&_(u)}return s}},a.prototype._getRootRect=function(){var t;if(this.root&&!x(this.root))t=T(this.root);else{var e=x(this.root)?this.root:n,o=e.documentElement,s=e.body;t={top:0,left:0,right:o.clientWidth||s.clientWidth,width:o.clientWidth||s.clientWidth,bottom:o.clientHeight||s.clientHeight,height:o.clientHeight||s.clientHeight}}return this._expandRectByRootMargin(t)},a.prototype._expandRectByRootMargin=function(t){var e=this._rootMarginValues.map(function(s,u){return s.unit=="px"?s.value:s.value*(u%2?t.width:t.height)/100}),o={top:t.top-e[0],right:t.right+e[1],bottom:t.bottom+e[2],left:t.left-e[3]};return o.width=o.right-o.left,o.height=o.bottom-o.top,o},a.prototype._hasCrossedThreshold=function(t,e){var o=t&&t.isIntersecting?t.intersectionRatio||0:-1,s=e.isIntersecting?e.intersectionRatio||0:-1;if(o!==s)for(var u=0;u<this.thresholds.length;u++){var O=this.thresholds[u];if(O==o||O==s||O<o!=O<s)return!0}},a.prototype._rootIsInDom=function(){return!this.root||h(n,this.root)},a.prototype._rootContainsTarget=function(t){var e=this.root&&(this.root.ownerDocument||this.root)||n;return h(e,t)&&(!this.root||e==t.ownerDocument)},a.prototype._registerInstance=function(){i.indexOf(this)<0&&i.push(this)},a.prototype._unregisterInstance=function(){var t=i.indexOf(this);t!=-1&&i.splice(t,1)};function m(){return window.performance&&performance.now&&performance.now()}function d(t,e){var o=null;return function(){o||(o=setTimeout(function(){t(),o=null},e))}}function c(t,e,o,s){typeof t.addEventListener=="function"?t.addEventListener(e,o,s):typeof t.attachEvent=="function"&&t.attachEvent("on"+e,o)}function l(t,e,o,s){typeof t.removeEventListener=="function"?t.removeEventListener(e,o,s):typeof t.detatchEvent=="function"&&t.detatchEvent("on"+e,o)}function v(t,e){var o=Math.max(t.top,e.top),s=Math.min(t.bottom,e.bottom),u=Math.max(t.left,e.left),O=Math.min(t.right,e.right),E=O-u,I=s-o;return E>=0&&I>=0&&{top:o,bottom:s,left:u,right:O,width:E,height:I}||null}function T(t){var e;try{e=t.getBoundingClientRect()}catch{}return e?(e.width&&e.height||(e={top:e.top,right:e.right,bottom:e.bottom,left:e.left,width:e.right-e.left,height:e.bottom-e.top}),e):y()}function y(){return{top:0,bottom:0,left:0,right:0,width:0,height:0}}function b(t){return!t||"x"in t?t:{top:t.top,y:t.top,bottom:t.bottom,left:t.left,x:t.left,right:t.right,width:t.width,height:t.height}}function R(t,e){var o=e.top-t.top,s=e.left-t.left;return{top:o,left:s,height:e.height,width:e.width,bottom:o+e.height,right:s+e.width}}function h(t,e){for(var o=e;o;){if(o==t)return!0;o=_(o)}return!1}function _(t){var e=t.parentNode;return t.nodeType==9&&t!=n?g(t):(e&&e.assignedSlot&&(e=e.assignedSlot.parentNode),e&&e.nodeType==11&&e.host?e.host:e)}function x(t){return t&&t.nodeType===9}window.IntersectionObserver=a,window.IntersectionObserverEntry=w}()),S}q();var C={exports:{}},H;function G(){return H||(H=1,function(g){var n=Object.prototype.hasOwnProperty,i="~";function p(){}Object.create&&(p.prototype=Object.create(null),new p().__proto__||(i=!1));function f(d,c,l){this.fn=d,this.context=c,this.once=l||!1}function w(d,c,l,v,T){if(typeof l!="function")throw new TypeError("The listener must be a function");var y=new f(l,v||d,T),b=i?i+c:c;return d._events[b]?d._events[b].fn?d._events[b]=[d._events[b],y]:d._events[b].push(y):(d._events[b]=y,d._eventsCount++),d}function a(d,c){--d._eventsCount===0?d._events=new p:delete d._events[c]}function m(){this._events=new p,this._eventsCount=0}m.prototype.eventNames=function(){var c=[],l,v;if(this._eventsCount===0)return c;for(v in l=this._events)n.call(l,v)&&c.push(i?v.slice(1):v);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(l)):c},m.prototype.listeners=function(c){var l=i?i+c:c,v=this._events[l];if(!v)return[];if(v.fn)return[v.fn];for(var T=0,y=v.length,b=new Array(y);T<y;T++)b[T]=v[T].fn;return b},m.prototype.listenerCount=function(c){var l=i?i+c:c,v=this._events[l];return v?v.fn?1:v.length:0},m.prototype.emit=function(c,l,v,T,y,b){var R=i?i+c:c;if(!this._events[R])return!1;var h=this._events[R],_=arguments.length,x,t;if(h.fn){switch(h.once&&this.removeListener(c,h.fn,void 0,!0),_){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,l),!0;case 3:return h.fn.call(h.context,l,v),!0;case 4:return h.fn.call(h.context,l,v,T),!0;case 5:return h.fn.call(h.context,l,v,T,y),!0;case 6:return h.fn.call(h.context,l,v,T,y,b),!0}for(t=1,x=new Array(_-1);t<_;t++)x[t-1]=arguments[t];h.fn.apply(h.context,x)}else{var e=h.length,o;for(t=0;t<e;t++)switch(h[t].once&&this.removeListener(c,h[t].fn,void 0,!0),_){case 1:h[t].fn.call(h[t].context);break;case 2:h[t].fn.call(h[t].context,l);break;case 3:h[t].fn.call(h[t].context,l,v);break;case 4:h[t].fn.call(h[t].context,l,v,T);break;default:if(!x)for(o=1,x=new Array(_-1);o<_;o++)x[o-1]=arguments[o];h[t].fn.apply(h[t].context,x)}}return!0},m.prototype.on=function(c,l,v){return w(this,c,l,v,!1)},m.prototype.once=function(c,l,v){return w(this,c,l,v,!0)},m.prototype.removeListener=function(c,l,v,T){var y=i?i+c:c;if(!this._events[y])return this;if(!l)return a(this,y),this;var b=this._events[y];if(b.fn)b.fn===l&&(!T||b.once)&&(!v||b.context===v)&&a(this,y);else{for(var R=0,h=[],_=b.length;R<_;R++)(b[R].fn!==l||T&&!b[R].once||v&&b[R].context!==v)&&h.push(b[R]);h.length?this._events[y]=h.length===1?h[0]:h:a(this,y)}return this},m.prototype.removeAllListeners=function(c){var l;return c?(l=i?i+c:c,this._events[l]&&a(this,l)):(this._events=new p,this._eventsCount=0),this},m.prototype.off=m.prototype.removeListener,m.prototype.addListener=m.prototype.on,m.prefixed=i,m.EventEmitter=m,g.exports=m}(C)),C.exports}var z=G(),W=Object.defineProperty,$=Object.getOwnPropertyDescriptor,Y=(g,n,i,p)=>{for(var f=$(n,i),w=g.length-1,a;w>=0;w--)(a=g[w])&&(f=a(n,i,f)||f);return f&&W(n,i,f),f};const B=60,j=(r=class{static on(n,i){r.events.on(n,i)}static off(n,i){r.events.off(n,i)}static once(n,i){r.events.once(n,i)}static checkCollisions(n,i){const p=i||Array.from(r.elements.keys()),f=n.getBoundingClientRect(),w=[];for(const a of p)if(a!==n){const m=a.getBoundingClientRect();m.left<=f.right&&m.right>=f.left&&m.top<=f.bottom&&m.bottom>=f.top&&w.push(a)}w.length&&r.onElementIntersection(n,w)}static isPositioned(n){return r.elements.has(n)}static getPositioningOptions(n){return r.elements.has(n)?r.elements.get(n):null}static position(n,i={}){const p={...F,...i};let f=n;for(;f!==document.body;)if(f=f.parentElement,f.classList.contains("sps-focused-task")){p.scrollParent=f,r.registeredScrollParents.has(f)||(r.registeredScrollParents.add(f),f.addEventListener("scroll",r.update));break}if(n.style.visibility="hidden",r.elements.size===0&&(window.addEventListener("resize",r.update),window.addEventListener("scroll",r.update)),!p.relativeTo)throw new Error("You must provide an element for the relativeTo option to position an element.");r.elements.set(n,p),k.onNextTick(()=>{r.fixElementPosition(n),r.viewportObserver.observe(n),n.style.visibility="",r.checkCollisions(n)})}static release(n){if(r.elements.has(n)){r.clearStyles(n);const i=r.elements.get(n);i.scrollParent&&(i.scrollParent.removeEventListener("scroll",r.update),r.registeredScrollParents.delete(i.scrollParent)),r.elements.delete(n),r.elements.size===0&&(window.removeEventListener("resize",r.update),window.removeEventListener("scroll",r.update)),r.viewportObserver.unobserve(n)}}static releaseAll(){for(const n of r.elements.keys())r.release(n)}static refresh(n){r.elements.has(n)&&(r.clearStyles(n),r.fixElementPosition(n),r.checkCollisions(n))}static refreshAll(){for(const n of r.elements.keys())r.refresh(n)}static reposition(n,i){if(r.elements.has(n)){const p=r.elements.get(n);r.elements.set(n,Object.assign(p,i)),r.refresh(n)}}static onViewportIntersection(n){for(const i of n){const p=Object.keys(IntersectionObserverEntry.prototype).reduce((f,w)=>({...f,[w]:i[w]}),{});p.rootBounds=p.rootBounds||r.getRootBounds(),r.events.emit("viewportIntersection",Object.freeze(p))}}static onElementIntersection(n,i){r.events.emit("elementIntersection",{target:n,intersectingWith:i})}static getRootBounds(){const n=Math.max(document.documentElement.clientWidth,window.innerWidth||0),i=Math.max(document.documentElement.clientHeight,window.innerHeight||0);return{x:0,y:B,left:0,top:B,right:n,bottom:i,height:i-B,width:n}}static clearStyles(n){Object.assign(n.style,{position:"",width:"",top:"",left:"",right:"",bottom:"",visibility:"",zIndex:""})}static fixElementPosition(n,i){if(!this.elements.has(n))return;const p=i||this.elements.get(n),f=this.getRootBounds(),w=n.getBoundingClientRect(),a=p.relativeTo.getBoundingClientRect(),{width:m}=p.useRelativeTargetWidth?a:w;Object.assign(n.style,{minWidth:`${m}px`,position:"fixed",zIndex:p.zIndex||""});let d,c;const l=p.position.split(" "),v=p.offsets[0]||0,T=p.offsets[1]||0;switch(d=0,c=0,l[0]){case"top":d=a.top-w.height-v;break;case"left":c=a.left-m-v;break;case"right":c=a.right+v;break;case"bottom":d=a.bottom+v;break;default:throw new Error(`${p.position} is not a valid position`)}switch(l[1]){case"left":c=a.left-T;break;case"top":d=a.top-T;break;case"middle":l[0]==="top"||l[0]==="bottom"?c=a.left+a.width/2-m/2+T:(l[0]==="left"||l[0]==="right")&&(d=a.top+a.height/2-w.height/2+T);break;case"bottom":d=a.bottom-w.height+T;break;case"right":c=a.right-m+T;break;default:throw new Error(`${p.position} is not a valid position`)}const y=d+w.height,b=c+w.width,R=`${Math.round(d)}px`,h=`${Math.round(f.bottom-y)}px`,_=`${Math.round(c)}px`,x=`${Math.round(f.right-b)}px`;switch(p.anchor){case P.TOP_LEFT:Object.assign(n.style,{top:R,bottom:"auto",left:_,right:"auto"});break;case P.TOP_RIGHT:Object.assign(n.style,{top:R,bottom:"auto",left:"auto",right:x});break;case P.BOTTOM_LEFT:Object.assign(n.style,{top:"auto",bottom:h,left:_,right:"auto"});break;case P.BOTTOM_RIGHT:Object.assign(n.style,{top:"auto",bottom:h,left:"auto",right:x});break}}static update(n){const i=r.elements.entries(),p=[];for(const[f,w]of i)(!n||n.target===document||n.target===w.scrollParent||n.target===window)&&(r.fixElementPosition(f,w),r.checkCollisions(f,p),p.push(f))}on(n,i){r.on(n,i)}off(n,i){r.off(n,i)}once(n,i){r.once(n,i)}isPositioned(n){return r.isPositioned(n)}getPositioningOptions(n){return r.getPositioningOptions(n)}position(n,i={}){r.position(n,i)}release(n){r.release(n)}releaseAll(){r.releaseAll()}refresh(n){r.refresh(n)}refreshAll(){r.refreshAll()}reposition(n,i){r.reposition(n,i)}},r.elements=new Map,r.registeredScrollParents=new Set,r.events=new z.EventEmitter,r.viewportObserver=new IntersectionObserver(r.onViewportIntersection,{rootMargin:`-${B}px 0px 0px`,threshold:1}),r);Y([k.lockedToAnimationFrames],j,"update");let J=j;D.DEFAULT_POSITIONING_OPTIONS=F,D.Position=A,D.PositionAnchor=P,D.PositioningService=J,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spscommerce/positioning",
|
|
3
3
|
"description": "Service for positioning dropdown/popup elements.",
|
|
4
|
-
"version": "8.33.
|
|
4
|
+
"version": "8.33.3",
|
|
5
5
|
"author": "SPS Commerce",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"repository": "https://github.com/spscommerce/woodland/tree/main/packages/@spscommerce/positioning",
|