@taiga-ui/font-watcher 0.4.0 → 0.5.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/index.cjs.js +4 -5
- package/index.esm.js +4 -5
- package/package.json +2 -2
package/index.cjs.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-unnecessary-condition, compat/compat */
|
|
4
3
|
const IFRAME = {
|
|
5
4
|
position: 'fixed',
|
|
6
5
|
visibility: 'hidden',
|
|
@@ -13,11 +12,11 @@ const BODY = {
|
|
|
13
12
|
};
|
|
14
13
|
function tuiFontSizeWatcher(callback, iframe = globalThis.document.createElement('iframe')) {
|
|
15
14
|
const resize = () => {
|
|
16
|
-
const { innerWidth = 0, outerWidth = 0, devicePixelRatio = 0, } = iframe.ownerDocument
|
|
15
|
+
const { innerWidth = 0, outerWidth = 0, devicePixelRatio = 0, } = iframe.ownerDocument.defaultView || {};
|
|
17
16
|
iframe.width = `${innerWidth === outerWidth ? innerWidth : innerWidth / devicePixelRatio}`;
|
|
18
17
|
};
|
|
19
|
-
iframe.ownerDocument
|
|
20
|
-
iframe.ownerDocument
|
|
18
|
+
iframe.ownerDocument.body.append(iframe);
|
|
19
|
+
iframe.ownerDocument.defaultView?.addEventListener('resize', resize);
|
|
21
20
|
const doc = iframe.contentDocument;
|
|
22
21
|
const observer = new ResizeObserver(() => callback(doc?.body.offsetHeight || 0));
|
|
23
22
|
Object.assign(iframe.style, IFRAME);
|
|
@@ -28,7 +27,7 @@ function tuiFontSizeWatcher(callback, iframe = globalThis.document.createElement
|
|
|
28
27
|
resize();
|
|
29
28
|
return () => {
|
|
30
29
|
observer.disconnect();
|
|
31
|
-
iframe.ownerDocument
|
|
30
|
+
iframe.ownerDocument.defaultView?.removeEventListener('resize', resize);
|
|
32
31
|
iframe.remove();
|
|
33
32
|
};
|
|
34
33
|
}
|
package/index.esm.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unnecessary-condition, compat/compat */
|
|
2
1
|
const IFRAME = {
|
|
3
2
|
position: 'fixed',
|
|
4
3
|
visibility: 'hidden',
|
|
@@ -11,11 +10,11 @@ const BODY = {
|
|
|
11
10
|
};
|
|
12
11
|
function tuiFontSizeWatcher(callback, iframe = globalThis.document.createElement('iframe')) {
|
|
13
12
|
const resize = () => {
|
|
14
|
-
const { innerWidth = 0, outerWidth = 0, devicePixelRatio = 0, } = iframe.ownerDocument
|
|
13
|
+
const { innerWidth = 0, outerWidth = 0, devicePixelRatio = 0, } = iframe.ownerDocument.defaultView || {};
|
|
15
14
|
iframe.width = `${innerWidth === outerWidth ? innerWidth : innerWidth / devicePixelRatio}`;
|
|
16
15
|
};
|
|
17
|
-
iframe.ownerDocument
|
|
18
|
-
iframe.ownerDocument
|
|
16
|
+
iframe.ownerDocument.body.append(iframe);
|
|
17
|
+
iframe.ownerDocument.defaultView?.addEventListener('resize', resize);
|
|
19
18
|
const doc = iframe.contentDocument;
|
|
20
19
|
const observer = new ResizeObserver(() => callback(doc?.body.offsetHeight || 0));
|
|
21
20
|
Object.assign(iframe.style, IFRAME);
|
|
@@ -26,7 +25,7 @@ function tuiFontSizeWatcher(callback, iframe = globalThis.document.createElement
|
|
|
26
25
|
resize();
|
|
27
26
|
return () => {
|
|
28
27
|
observer.disconnect();
|
|
29
|
-
iframe.ownerDocument
|
|
28
|
+
iframe.ownerDocument.defaultView?.removeEventListener('resize', resize);
|
|
30
29
|
iframe.remove();
|
|
31
30
|
};
|
|
32
31
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taiga-ui/font-watcher",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Taiga UI font watcher",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "https://github.com/taiga-family/
|
|
7
|
+
"url": "https://github.com/taiga-family/utils.git"
|
|
8
8
|
},
|
|
9
9
|
"license": "Apache-2.0",
|
|
10
10
|
"publishConfig": {
|