@karmo-co/drift-kit-public 25.14.0 → 25.16.0
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/components.js +51 -4
- package/drift-kit.min.css +2 -2
- package/package.json +1 -1
package/components.js
CHANGED
|
@@ -136,9 +136,50 @@
|
|
|
136
136
|
'data-fidelity', 'data-device'
|
|
137
137
|
];
|
|
138
138
|
var PAGE_DROPS = { 'data-tone-fill': 1, 'data-surface': 1 };
|
|
139
|
+
var live = typeof Map === 'function' ? new Map() : null;
|
|
140
|
+
var watcher = null;
|
|
141
|
+
function inLive(node) {
|
|
142
|
+
var it = live.keys(), k;
|
|
143
|
+
while (!(k = it.next()).done)
|
|
144
|
+
if (k.value === node || k.value.contains(node))
|
|
145
|
+
return true;
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
function watch() {
|
|
149
|
+
if (watcher || typeof MutationObserver !== 'function' || !document.documentElement)
|
|
150
|
+
return;
|
|
151
|
+
watcher = new MutationObserver(function (records) {
|
|
152
|
+
for (var i = 0; i < records.length; i++) {
|
|
153
|
+
if (inLive(records[i].target))
|
|
154
|
+
continue;
|
|
155
|
+
live.forEach(function (o, el) {
|
|
156
|
+
if (!el.isConnected)
|
|
157
|
+
live.delete(el);
|
|
158
|
+
else if (o.reference.isConnected)
|
|
159
|
+
stamp(el, o.reference, o.opts);
|
|
160
|
+
});
|
|
161
|
+
unwatch();
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
watcher.observe(document.documentElement, { attributes: true, subtree: true, attributeFilter: LEGS });
|
|
166
|
+
}
|
|
167
|
+
function unwatch() {
|
|
168
|
+
if (watcher && live && live.size === 0) {
|
|
169
|
+
watcher.disconnect();
|
|
170
|
+
watcher = null;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
139
173
|
function adopt(floating, reference, opts) {
|
|
140
174
|
if (!floating || !reference || !reference.closest)
|
|
141
175
|
return;
|
|
176
|
+
stamp(floating, reference, opts);
|
|
177
|
+
if (live) {
|
|
178
|
+
live.set(floating, { reference: reference, opts: opts });
|
|
179
|
+
watch();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function stamp(floating, reference, opts) {
|
|
142
183
|
var page = !!(opts && opts.page);
|
|
143
184
|
var asked = page && reference.closest('[data-menu-tone]');
|
|
144
185
|
var menuTone = asked ? asked.getAttribute('data-menu-tone') : null;
|
|
@@ -150,15 +191,21 @@
|
|
|
150
191
|
value = null;
|
|
151
192
|
if (page && leg === 'data-tone')
|
|
152
193
|
value = menuTone === 'inverse' ? 'inverse' : null;
|
|
153
|
-
if (value !== null)
|
|
154
|
-
floating.
|
|
155
|
-
|
|
194
|
+
if (value !== null) {
|
|
195
|
+
if (floating.getAttribute(leg) !== value)
|
|
196
|
+
floating.setAttribute(leg, value);
|
|
197
|
+
}
|
|
198
|
+
else if (floating.hasAttribute(leg))
|
|
156
199
|
floating.removeAttribute(leg);
|
|
157
200
|
}
|
|
158
201
|
}
|
|
159
202
|
function release(floating) {
|
|
160
203
|
if (!floating)
|
|
161
204
|
return;
|
|
205
|
+
if (live) {
|
|
206
|
+
live.delete(floating);
|
|
207
|
+
unwatch();
|
|
208
|
+
}
|
|
162
209
|
for (var i = 0; i < LEGS.length; i++)
|
|
163
210
|
floating.removeAttribute(LEGS[i]);
|
|
164
211
|
}
|
|
@@ -612,7 +659,7 @@
|
|
|
612
659
|
root.setAttribute('data-dk-cascade-after', 'leave');
|
|
613
660
|
var t = pat === 'slide'
|
|
614
661
|
? msOf(region, '--dk-motion-page-slide-duration')
|
|
615
|
-
:
|
|
662
|
+
: msOf(region, '--dk-motion-page-fade-exit-duration') + msOf(region, '--dk-motion-page-fade-duration');
|
|
616
663
|
if (parts)
|
|
617
664
|
t = msOf(region, '--dk-motion-exit-large-duration');
|
|
618
665
|
clearTimeout(timer);
|