@daguanren21/vue-resize-sensor 2.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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Franck Freiburger
4
+ Copyright (c) 2026 Community maintainers of the vue2-pdf ESM rebuild
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # @daguanren21/vue-resize-sensor
2
+
3
+ Community-maintained ESM packaging of **[vue-resize-sensor](https://github.com/FranckFreiburger/vue-resize-sensor)** by **Franck Freiburger**.
4
+
5
+ Used by [`@daguanren21/vue-pdf`](https://www.npmjs.com/package/@daguanren21/vue-pdf).
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pnpm add @daguanren21/vue-resize-sensor
11
+ pnpm add vue@^2.7
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ```ts
17
+ import ResizeSensor from '@daguanren21/vue-resize-sensor'
18
+ ```
19
+
20
+ ## Credits
21
+
22
+ - Original: [FranckFreiburger/vue-resize-sensor](https://github.com/FranckFreiburger/vue-resize-sensor)
23
+
24
+ ## License
25
+
26
+ MIT
@@ -0,0 +1,6 @@
1
+ import { default as default_2 } from './resize-sensor.vue';
2
+
3
+ export { default_2 as ResizeSensor }
4
+ export default default_2;
5
+
6
+ export { }
@@ -0,0 +1 @@
1
+ @keyframes resizeSensorVisibility{0%{top:0}}
@@ -0,0 +1,93 @@
1
+ function o(t, i, e, l, r, d, a, f) {
2
+ var s = typeof t == "function" ? t.options : t;
3
+ return {
4
+ exports: t,
5
+ options: s
6
+ };
7
+ }
8
+ const n = {
9
+ // thanks to https://github.com/marcj/css-element-queries
10
+ props: {
11
+ initial: {
12
+ type: Boolean,
13
+ default: !1
14
+ }
15
+ },
16
+ data: function() {
17
+ return {
18
+ size: {
19
+ width: -1,
20
+ height: -1
21
+ }
22
+ };
23
+ },
24
+ methods: {
25
+ reset: function() {
26
+ var t = this.$el.firstChild, i = this.$el.lastChild;
27
+ t.scrollLeft = 1e5, t.scrollTop = 1e5, i.scrollLeft = 1e5, i.scrollTop = 1e5;
28
+ },
29
+ update: function() {
30
+ this.size.width = this.$el.offsetWidth, this.size.height = this.$el.offsetHeight;
31
+ }
32
+ },
33
+ watch: {
34
+ size: {
35
+ deep: !0,
36
+ handler: function(t) {
37
+ this.reset(), this.$emit("resize", { width: this.size.width, height: this.size.height });
38
+ }
39
+ }
40
+ },
41
+ render: function(t) {
42
+ var i = "position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: hidden; z-index: -1; visibility: hidden;", e = "position: absolute; left: 0; top: 0;";
43
+ return t("div", {
44
+ style: i + "animation-name: resizeSensorVisibility;",
45
+ on: {
46
+ "~animationstart": this.update
47
+ }
48
+ }, [
49
+ t("div", {
50
+ style: i,
51
+ on: {
52
+ scroll: this.update
53
+ }
54
+ }, [
55
+ t("div", {
56
+ style: e + "width: 100000px; height: 100000px;"
57
+ })
58
+ ]),
59
+ t("div", {
60
+ style: i,
61
+ on: {
62
+ scroll: this.update
63
+ }
64
+ }, [
65
+ t("div", {
66
+ style: e + "width: 200%; height: 200%;"
67
+ })
68
+ ])
69
+ ]);
70
+ },
71
+ beforeDestroy: function() {
72
+ this.$emit("resize", { width: 0, height: 0 }), this.$emit("resizeSensorBeforeDestroy");
73
+ },
74
+ mounted: function() {
75
+ if (this.initial === !0 && this.$nextTick(this.update), this.$el.offsetParent !== this.$el.parentNode && (this.$el.parentNode.style.position = "relative"), "attachEvent" in this.$el && !("AnimationEvent" in window)) {
76
+ var t = function() {
77
+ this.update(), i();
78
+ }.bind(this), i = function() {
79
+ this.$el.detachEvent("onresize", t), this.$off("resizeSensorBeforeDestroy", i);
80
+ }.bind(this);
81
+ this.$el.attachEvent("onresize", t), this.$on("resizeSensorBeforeDestroy", i), this.reset();
82
+ }
83
+ }
84
+ };
85
+ var h = /* @__PURE__ */ o(
86
+ n
87
+ );
88
+ const u = h.exports;
89
+ export {
90
+ u as ResizeSensor,
91
+ u as default
92
+ };
93
+ //# sourceMappingURL=vue-resize-sensor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vue-resize-sensor.js","sources":["../src/resize-sensor.vue"],"sourcesContent":["<style>\n@keyframes resizeSensorVisibility {\n\tfrom { top: 0; }\n}\n</style>\n\n<script>\n\"use strict\";\n\nexport default {\n\n\t// thanks to https://github.com/marcj/css-element-queries\n\tprops: {\n\t\tinitial: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t}\n\t},\n\tdata: function() {\n\t\treturn {\n\t\t\tsize: {\n\t\t\t\twidth: -1,\n\t\t\t\theight: -1\n\t\t\t}\n\t\t}\n\t},\n\tmethods: {\n\t\treset: function() {\n\n\t\t\tvar expand = this.$el.firstChild;\n\t\t\tvar shrink = this.$el.lastChild;\n\t\t\texpand.scrollLeft = 100000;\n\t\t\texpand.scrollTop = 100000;\n\t\t\tshrink.scrollLeft = 100000;\n\t\t\tshrink.scrollTop = 100000;\n\t\t},\n\t\tupdate: function() {\n\t\t\t\n\t\t\tthis.size.width = this.$el.offsetWidth;\n\t\t\tthis.size.height = this.$el.offsetHeight;\n\t\t}\n\t},\n\twatch: {\n\t\tsize: {\n\t\t\tdeep: true,\n\t\t\thandler: function(size) {\n\t\t\t\t\n\t\t\t\tthis.reset();\n\t\t\t\tthis.$emit('resize', { width: this.size.width, height: this.size.height });\n\t\t\t}\n\t\t}\n\t},\n\trender: function(create) {\n\t\t\n\t\tvar style = 'position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: hidden; z-index: -1; visibility: hidden;';\n\t\tvar styleChild = 'position: absolute; left: 0; top: 0;';\n\n\t\treturn create('div', {\n\t\t\tstyle: style + 'animation-name: resizeSensorVisibility;',\n\t\t\ton: {\n\t\t\t\t'~animationstart': this.update\n\t\t\t}\n\t\t},[\n\t\t\tcreate('div', {\n\t\t\t\tstyle: style,\n\t\t\t\ton: {\n\t\t\t\t\tscroll: this.update\n\t\t\t\t}\n\t\t\t}, [\n\t\t\t\tcreate('div', {\n\t\t\t\t\tstyle: styleChild + 'width: 100000px; height: 100000px;'\n\t\t\t\t})\n\t\t\t]),\n\t\t\tcreate('div', {\n\t\t\t\tstyle: style,\n\t\t\t\ton: {\n\t\t\t\t\tscroll: this.update\n\t\t\t\t}\n\t\t\t}, [\n\t\t\t\tcreate('div', {\n\t\t\t\t\tstyle: styleChild + 'width: 200%; height: 200%;'\n\t\t\t\t})\n\t\t\t]),\n\t\t]);\n\t},\n\tbeforeDestroy: function() {\n\t\t\n\t\tthis.$emit('resize', { width: 0, height: 0 });\n\t\tthis.$emit('resizeSensorBeforeDestroy');\n\t},\n\tmounted: function() {\n\n\t\tif ( this.initial === true )\n\t\t\tthis.$nextTick(this.update);\n\t\t\n\t\tif ( this.$el.offsetParent !== this.$el.parentNode )\n\t\t\tthis.$el.parentNode.style.position = 'relative';\n\n\t\tif ( 'attachEvent' in this.$el && !('AnimationEvent' in window) ) {\n\n\t\t\tvar onresizeHandler = function() {\n\n\t\t\t\tthis.update();\n\t\t\t\tremoveOnresizeEvent();\n\t\t\t}.bind(this);\n\t\t\n\t\t\tvar removeOnresizeEvent = function() {\n\t\t\t\t\n\t\t\t\tthis.$el.detachEvent('onresize', onresizeHandler);\n\t\t\t\tthis.$off('resizeSensorBeforeDestroy', removeOnresizeEvent);\n\t\t\t}.bind(this);\n\t\t\t\n\t\t\tthis.$el.attachEvent('onresize', onresizeHandler);\n\t\t\tthis.$on('resizeSensorBeforeDestroy', removeOnresizeEvent);\n\t\t\tthis.reset();\n\t\t}\n\t}\n}\n\n</script>\n"],"names":["_sfc_main","expand","shrink","size","create","style","styleChild","onresizeHandler","removeOnresizeEvent"],"mappings":";;;;;;;AASA,MAAAA,IAAA;AAAA;AAAA,EAGA,OAAA;AAAA,IACA,SAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,IACA;AAAA,EACA;AAAA,EACA,MAAA,WAAA;AACA,WAAA;AAAA,MACA,MAAA;AAAA,QACA,OAAA;AAAA,QACA,QAAA;AAAA,MACA;AAAA,IACA;AAAA,EACA;AAAA,EACA,SAAA;AAAA,IACA,OAAA,WAAA;AAEA,UAAAC,IAAA,KAAA,IAAA,YACAC,IAAA,KAAA,IAAA;AACA,MAAAD,EAAA,aAAA,KACAA,EAAA,YAAA,KACAC,EAAA,aAAA,KACAA,EAAA,YAAA;AAAA,IACA;AAAA,IACA,QAAA,WAAA;AAEA,WAAA,KAAA,QAAA,KAAA,IAAA,aACA,KAAA,KAAA,SAAA,KAAA,IAAA;AAAA,IACA;AAAA,EACA;AAAA,EACA,OAAA;AAAA,IACA,MAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA,SAAAC,GAAA;AAEA,aAAA,MAAA,GACA,KAAA,MAAA,UAAA,EAAA,OAAA,KAAA,KAAA,OAAA,QAAA,KAAA,KAAA,OAAA,CAAA;AAAA,MACA;AAAA,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/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@daguanren21/vue-resize-sensor",
3
+ "version": "2.1.0",
4
+ "description": "Community-maintained ESM packaging of Franck Freiburger's vue-resize-sensor for Vue 2.7",
5
+ "type": "module",
6
+ "main": "./dist/vue-resize-sensor.js",
7
+ "module": "./dist/vue-resize-sensor.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/vue-resize-sensor.js",
13
+ "default": "./dist/vue-resize-sensor.js"
14
+ },
15
+ "./style.css": "./dist/vue-resize-sensor.css"
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "src",
20
+ "README.md",
21
+ "LICENSE"
22
+ ],
23
+ "sideEffects": [
24
+ "**/*.css",
25
+ "**/*.vue"
26
+ ],
27
+ "keywords": [
28
+ "vue",
29
+ "vue2",
30
+ "resize",
31
+ "sensor",
32
+ "detect",
33
+ "esm"
34
+ ],
35
+ "author": "Franck FREIBURGER",
36
+ "contributors": [
37
+ "daguanren21 (community ESM packaging maintainer)"
38
+ ],
39
+ "license": "MIT",
40
+ "peerDependencies": {
41
+ "vue": "^2.7.0"
42
+ },
43
+ "devDependencies": {
44
+ "@types/node": "^26.1.1",
45
+ "@vitejs/plugin-vue2": "^2.3.4",
46
+ "vite": "^7.3.6",
47
+ "vite-plugin-dts": "^4.5.4",
48
+ "vue": "^2.7.16",
49
+ "vue-template-compiler": "^2.7.16"
50
+ },
51
+ "repository": {
52
+ "type": "git",
53
+ "url": "git+https://github.com/daguanren21/vue-pdf.git",
54
+ "directory": "packages/vue-resize-sensor"
55
+ },
56
+ "bugs": {
57
+ "url": "https://github.com/daguanren21/vue-pdf/issues"
58
+ },
59
+ "homepage": "https://github.com/daguanren21/vue-pdf/tree/master/packages/vue-resize-sensor#readme",
60
+ "publishConfig": {
61
+ "access": "public"
62
+ },
63
+ "scripts": {
64
+ "build": "vite build",
65
+ "dev": "vite build --watch",
66
+ "typecheck": "tsc -p tsconfig.json --noEmit"
67
+ }
68
+ }
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ import ResizeSensor from './resize-sensor.vue'
2
+
3
+ export { ResizeSensor }
4
+ export default ResizeSensor
@@ -0,0 +1,120 @@
1
+ <style>
2
+ @keyframes resizeSensorVisibility {
3
+ from { top: 0; }
4
+ }
5
+ </style>
6
+
7
+ <script>
8
+ "use strict";
9
+
10
+ export default {
11
+
12
+ // thanks to https://github.com/marcj/css-element-queries
13
+ props: {
14
+ initial: {
15
+ type: Boolean,
16
+ default: false,
17
+ }
18
+ },
19
+ data: function() {
20
+ return {
21
+ size: {
22
+ width: -1,
23
+ height: -1
24
+ }
25
+ }
26
+ },
27
+ methods: {
28
+ reset: function() {
29
+
30
+ var expand = this.$el.firstChild;
31
+ var shrink = this.$el.lastChild;
32
+ expand.scrollLeft = 100000;
33
+ expand.scrollTop = 100000;
34
+ shrink.scrollLeft = 100000;
35
+ shrink.scrollTop = 100000;
36
+ },
37
+ update: function() {
38
+
39
+ this.size.width = this.$el.offsetWidth;
40
+ this.size.height = this.$el.offsetHeight;
41
+ }
42
+ },
43
+ watch: {
44
+ size: {
45
+ deep: true,
46
+ handler: function(size) {
47
+
48
+ this.reset();
49
+ this.$emit('resize', { width: this.size.width, height: this.size.height });
50
+ }
51
+ }
52
+ },
53
+ render: function(create) {
54
+
55
+ var style = 'position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: hidden; z-index: -1; visibility: hidden;';
56
+ var styleChild = 'position: absolute; left: 0; top: 0;';
57
+
58
+ return create('div', {
59
+ style: style + 'animation-name: resizeSensorVisibility;',
60
+ on: {
61
+ '~animationstart': this.update
62
+ }
63
+ },[
64
+ create('div', {
65
+ style: style,
66
+ on: {
67
+ scroll: this.update
68
+ }
69
+ }, [
70
+ create('div', {
71
+ style: styleChild + 'width: 100000px; height: 100000px;'
72
+ })
73
+ ]),
74
+ create('div', {
75
+ style: style,
76
+ on: {
77
+ scroll: this.update
78
+ }
79
+ }, [
80
+ create('div', {
81
+ style: styleChild + 'width: 200%; height: 200%;'
82
+ })
83
+ ]),
84
+ ]);
85
+ },
86
+ beforeDestroy: function() {
87
+
88
+ this.$emit('resize', { width: 0, height: 0 });
89
+ this.$emit('resizeSensorBeforeDestroy');
90
+ },
91
+ mounted: function() {
92
+
93
+ if ( this.initial === true )
94
+ this.$nextTick(this.update);
95
+
96
+ if ( this.$el.offsetParent !== this.$el.parentNode )
97
+ this.$el.parentNode.style.position = 'relative';
98
+
99
+ if ( 'attachEvent' in this.$el && !('AnimationEvent' in window) ) {
100
+
101
+ var onresizeHandler = function() {
102
+
103
+ this.update();
104
+ removeOnresizeEvent();
105
+ }.bind(this);
106
+
107
+ var removeOnresizeEvent = function() {
108
+
109
+ this.$el.detachEvent('onresize', onresizeHandler);
110
+ this.$off('resizeSensorBeforeDestroy', removeOnresizeEvent);
111
+ }.bind(this);
112
+
113
+ this.$el.attachEvent('onresize', onresizeHandler);
114
+ this.$on('resizeSensorBeforeDestroy', removeOnresizeEvent);
115
+ this.reset();
116
+ }
117
+ }
118
+ }
119
+
120
+ </script>
@@ -0,0 +1,5 @@
1
+ declare module '*.vue' {
2
+ import type { DefineComponent } from 'vue'
3
+ const component: DefineComponent<Record<string, unknown>, Record<string, unknown>, any>
4
+ export default component
5
+ }