@sepveneto/free-dom 0.4.1 → 0.4.2

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.css CHANGED
@@ -1,4 +1,4 @@
1
- /* ../../../../../../../tmp/tmp-1788-ZUBazkQPDiBa/core/src/style/index.css */
1
+ /* ../../../../../../../tmp/tmp-1778-6uk8ditWyl3v/core/src/style/index.css */
2
2
  :root {
3
3
  --free-dom-theme: #4089ef;
4
4
  --free-dom-line: var(--free-dom-theme);
package/dist/index.js CHANGED
@@ -242,12 +242,31 @@ var FreeDom = (0, import_vue_demi2.defineComponent)({
242
242
  init && triggerThrottle();
243
243
  init = true;
244
244
  });
245
+ const rectBound = (0, import_core.useElementBounding)(widgetRef);
246
+ const unwatchHeight = (0, import_vue_demi2.watch)(rectBound.height, (height) => {
247
+ if (height) {
248
+ _rect.height = height;
249
+ unwatchHeight();
250
+ }
251
+ });
252
+ const unwatchWidth = (0, import_vue_demi2.watch)(rectBound.width, (width) => {
253
+ if (width) {
254
+ _rect.width = width;
255
+ unwatchWidth();
256
+ }
257
+ });
245
258
  (0, import_vue_demi2.onMounted)(async () => {
246
259
  SceneContext?.register(uuid, context);
247
260
  await (0, import_vue_demi2.nextTick)();
248
261
  const rect = widgetRef.value.getBoundingClientRect();
249
262
  _rect.width = _rect.width || rect.width;
263
+ if (_rect.width) {
264
+ unwatchWidth();
265
+ }
250
266
  _rect.height = _rect.height || rect.height;
267
+ if (_rect.height) {
268
+ unwatchHeight();
269
+ }
251
270
  _rect.x = _rect.x || 0;
252
271
  _rect.y = _rect.y || 0;
253
272
  trigger();
package/dist/index.mjs CHANGED
@@ -17,7 +17,8 @@ import {
17
17
  reactive,
18
18
  isVue2,
19
19
  shallowRef,
20
- watchEffect
20
+ watchEffect,
21
+ watch as watch2
21
22
  } from "vue-demi";
22
23
 
23
24
  // src/hooks/use-normalize-style.ts
@@ -125,7 +126,7 @@ function useResize(startX, startY, rect, dot, diagonal, snapGrid, callbacks) {
125
126
  }
126
127
 
127
128
  // src/components/freeDom.ts
128
- import { onClickOutside, useThrottleFn } from "@vueuse/core";
129
+ import { onClickOutside, useThrottleFn, useElementBounding } from "@vueuse/core";
129
130
  import { v4 as uuidv4 } from "uuid";
130
131
  var Dots = ["t", "r", "l", "b", "lt", "lb", "rt", "rb"];
131
132
  var FreeDom = defineComponent({
@@ -229,12 +230,31 @@ var FreeDom = defineComponent({
229
230
  init && triggerThrottle();
230
231
  init = true;
231
232
  });
233
+ const rectBound = useElementBounding(widgetRef);
234
+ const unwatchHeight = watch2(rectBound.height, (height) => {
235
+ if (height) {
236
+ _rect.height = height;
237
+ unwatchHeight();
238
+ }
239
+ });
240
+ const unwatchWidth = watch2(rectBound.width, (width) => {
241
+ if (width) {
242
+ _rect.width = width;
243
+ unwatchWidth();
244
+ }
245
+ });
232
246
  onMounted(async () => {
233
247
  SceneContext?.register(uuid, context);
234
248
  await nextTick();
235
249
  const rect = widgetRef.value.getBoundingClientRect();
236
250
  _rect.width = _rect.width || rect.width;
251
+ if (_rect.width) {
252
+ unwatchWidth();
253
+ }
237
254
  _rect.height = _rect.height || rect.height;
255
+ if (_rect.height) {
256
+ unwatchHeight();
257
+ }
238
258
  _rect.x = _rect.x || 0;
239
259
  _rect.y = _rect.y || 0;
240
260
  trigger();
@@ -461,7 +481,7 @@ var FreeDom = defineComponent({
461
481
 
462
482
  // src/components/freeDomWrap.ts
463
483
  import { defineComponent as defineComponent3, shallowRef as shallowRef3, h as h3, provide, reactive as reactive3, ref as ref4, toRefs } from "vue-demi";
464
- import { useElementBounding } from "@vueuse/core";
484
+ import { useElementBounding as useElementBounding2 } from "@vueuse/core";
465
485
 
466
486
  // src/components/markLine.ts
467
487
  import { h as h2, defineComponent as defineComponent2, shallowRef as shallowRef2, ref as ref3, reactive as reactive2, inject as inject2, onBeforeUnmount } from "vue-demi";
@@ -655,7 +675,7 @@ var FreeDomWrap = defineComponent3({
655
675
  props: freeDomWrapProps,
656
676
  setup(props) {
657
677
  const rectRef = shallowRef3(null);
658
- const rect = useElementBounding(rectRef);
678
+ const rect = useElementBounding2(rectRef);
659
679
  const nodes = ref4([]);
660
680
  function register(uuid, node) {
661
681
  nodes.value.push({ uuid, node });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sepveneto/free-dom",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",