@zag-js/auto-resize 1.0.2 → 1.1.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/dist/index.js +9 -5
- package/dist/index.mjs +9 -5
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -46,10 +46,12 @@ var autoresizeTextarea = (el) => {
|
|
|
46
46
|
const win = domQuery.getWindow(el);
|
|
47
47
|
const doc = domQuery.getDocument(el);
|
|
48
48
|
const resize = () => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
requestAnimationFrame(() => {
|
|
50
|
+
el.style.height = "auto";
|
|
51
|
+
const borderTopWidth = parseInt(style.borderTopWidth, 10);
|
|
52
|
+
const borderBottomWidth = parseInt(style.borderBottomWidth, 10);
|
|
53
|
+
el.style.height = `${el.scrollHeight + borderTopWidth + borderBottomWidth}px`;
|
|
54
|
+
});
|
|
53
55
|
};
|
|
54
56
|
el.addEventListener("input", resize);
|
|
55
57
|
const elementPrototype = Object.getPrototypeOf(el);
|
|
@@ -61,7 +63,9 @@ var autoresizeTextarea = (el) => {
|
|
|
61
63
|
resize();
|
|
62
64
|
}
|
|
63
65
|
});
|
|
64
|
-
const resizeObserver = new win.ResizeObserver(() =>
|
|
66
|
+
const resizeObserver = new win.ResizeObserver(() => {
|
|
67
|
+
requestAnimationFrame(() => resize());
|
|
68
|
+
});
|
|
65
69
|
resizeObserver.observe(el);
|
|
66
70
|
const attrObserver = new win.MutationObserver(() => resize());
|
|
67
71
|
attrObserver.observe(el, { attributes: true, attributeFilter: ["rows", "placeholder"] });
|
package/dist/index.mjs
CHANGED
|
@@ -44,10 +44,12 @@ var autoresizeTextarea = (el) => {
|
|
|
44
44
|
const win = getWindow(el);
|
|
45
45
|
const doc = getDocument(el);
|
|
46
46
|
const resize = () => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
requestAnimationFrame(() => {
|
|
48
|
+
el.style.height = "auto";
|
|
49
|
+
const borderTopWidth = parseInt(style.borderTopWidth, 10);
|
|
50
|
+
const borderBottomWidth = parseInt(style.borderBottomWidth, 10);
|
|
51
|
+
el.style.height = `${el.scrollHeight + borderTopWidth + borderBottomWidth}px`;
|
|
52
|
+
});
|
|
51
53
|
};
|
|
52
54
|
el.addEventListener("input", resize);
|
|
53
55
|
const elementPrototype = Object.getPrototypeOf(el);
|
|
@@ -59,7 +61,9 @@ var autoresizeTextarea = (el) => {
|
|
|
59
61
|
resize();
|
|
60
62
|
}
|
|
61
63
|
});
|
|
62
|
-
const resizeObserver = new win.ResizeObserver(() =>
|
|
64
|
+
const resizeObserver = new win.ResizeObserver(() => {
|
|
65
|
+
requestAnimationFrame(() => resize());
|
|
66
|
+
});
|
|
63
67
|
resizeObserver.observe(el);
|
|
64
68
|
const attrObserver = new win.MutationObserver(() => resize());
|
|
65
69
|
attrObserver.observe(el, { attributes: true, attributeFilter: ["rows", "placeholder"] });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/auto-resize",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Autoresize utilities for the web",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@zag-js/dom-query": "1.0
|
|
25
|
+
"@zag-js/dom-query": "1.1.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"clean-package": "2.2.0"
|