@thangdevalone/meeting-grid-layout-vue 1.5.7 → 1.5.9

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/README.md CHANGED
@@ -57,6 +57,8 @@ Wraps the grid and provides layout via `provide`/`inject`.
57
57
  | `float-breakpoints` | `PipBreakpoint[]` | - | Responsive breakpoints for auto-float PiP (see [Responsive PiP](#responsive-pip)) |
58
58
  | `pip-index` | `number` | `1` | Which participant (0 or 1) is the floating PiP in 2-person mode |
59
59
  | `pin-only` | `boolean` | `false` | Mobile/tablet pin-only mode: page 0 = pinned full-screen, page 1+ = others gallery (≤1024px) |
60
+ | `disable-float` | `boolean` | `false` | Disable Floating PiP in 2-person mode; shows standard gallery grid instead |
61
+ | `disable-animation` | `boolean` | `false` | Disable all spring/transition animations globally; items snap instantly |
60
62
  | `tag` | `string` | `'div'` | Root HTML element tag |
61
63
 
62
64
  ### `<GridItem>`
package/dist/index.cjs CHANGED
@@ -173,6 +173,16 @@ const GridContainer = vue.defineComponent({
173
173
  type: Boolean,
174
174
  default: false
175
175
  },
176
+ /**
177
+ * Disable all animations globally.
178
+ * When true, all grid items and float items render without
179
+ * spring/transition animations. Items snap to positions instantly.
180
+ * @default false
181
+ */
182
+ disableAnimation: {
183
+ type: Boolean,
184
+ default: false
185
+ },
176
186
  /** HTML tag to render */
177
187
  tag: {
178
188
  type: String,
@@ -205,8 +215,9 @@ const GridContainer = vue.defineComponent({
205
215
  const grid = useMeetGrid(gridOptions);
206
216
  vue.provide(GridContextKey, {
207
217
  grid,
208
- springPreset: props.springPreset,
209
- dimensions
218
+ springPreset: vue.toRef(props, "springPreset"),
219
+ dimensions,
220
+ disableAnimation: vue.toRef(props, "disableAnimation")
210
221
  });
211
222
  return () => vue.h(
212
223
  props.tag,
@@ -253,7 +264,8 @@ const GridItem = vue.defineComponent({
253
264
  console.warn("GridItem must be used inside a GridContainer");
254
265
  return () => null;
255
266
  }
256
- const { grid, springPreset, dimensions: containerDimensions } = context;
267
+ const { grid, springPreset, dimensions: containerDimensions, disableAnimation: containerDisableAnimation } = context;
268
+ const noAnimation = vue.computed(() => containerDisableAnimation.value || props.disableAnimation);
257
269
  const position = vue.computed(() => grid.value.getPosition(props.index));
258
270
  const dimensions = vue.computed(() => grid.value.getItemDimensions(props.index));
259
271
  const contentDimensions = vue.computed(
@@ -331,9 +343,14 @@ const GridItem = vue.defineComponent({
331
343
  ([, w, h2]) => {
332
344
  if (isFloat.value && floatInitialized.value && w > 0 && h2 > 0) {
333
345
  const pos = getFloatCornerPos(floatAnchor.value);
334
- const springCfg = { type: "spring", stiffness: 400, damping: 30 };
335
- motionV.animate(x, pos.x, springCfg);
336
- motionV.animate(y, pos.y, springCfg);
346
+ if (noAnimation.value) {
347
+ x.set(pos.x);
348
+ y.set(pos.y);
349
+ } else {
350
+ const springCfg = { type: "spring", stiffness: 400, damping: 30 };
351
+ motionV.animate(x, pos.x, springCfg);
352
+ motionV.animate(y, pos.y, springCfg);
353
+ }
337
354
  }
338
355
  }
339
356
  );
@@ -342,7 +359,7 @@ const GridItem = vue.defineComponent({
342
359
  return props.index === lastVisibleOthersIndex;
343
360
  });
344
361
  const hiddenCount = vue.computed(() => grid.value.hiddenCount);
345
- const springConfig = meetingGridLayoutCore.getSpringConfig(springPreset);
362
+ const springConfig = vue.computed(() => meetingGridLayoutCore.getSpringConfig(springPreset.value));
346
363
  const gridX = motionV.useMotionValue(0);
347
364
  const gridY = motionV.useMotionValue(0);
348
365
  const gridAnimReady = vue.ref(false);
@@ -351,7 +368,10 @@ const GridItem = vue.defineComponent({
351
368
  () => position.value.top,
352
369
  () => position.value.left,
353
370
  isFloat,
354
- isHidden
371
+ isHidden,
372
+ () => springConfig.value.stiffness,
373
+ () => springConfig.value.damping,
374
+ () => springConfig.value.mass
355
375
  ],
356
376
  ([, , floating, hidden]) => {
357
377
  if (floating || hidden) {
@@ -363,11 +383,15 @@ const GridItem = vue.defineComponent({
363
383
  gridX.set(pos.left);
364
384
  gridY.set(pos.top);
365
385
  gridAnimReady.value = true;
386
+ } else if (noAnimation.value) {
387
+ gridX.set(pos.left);
388
+ gridY.set(pos.top);
366
389
  } else {
367
390
  const cfg = {
368
391
  type: "spring",
369
- stiffness: springConfig.stiffness,
370
- damping: springConfig.damping
392
+ stiffness: springConfig.value.stiffness,
393
+ damping: springConfig.value.damping,
394
+ mass: springConfig.value.mass
371
395
  };
372
396
  motionV.animate(gridX, pos.left, cfg);
373
397
  motionV.animate(gridY, pos.top, cfg);
@@ -401,9 +425,14 @@ const GridItem = vue.defineComponent({
401
425
  const nearestCorner = findFloatNearestCorner(currentX, currentY);
402
426
  floatAnchor.value = nearestCorner;
403
427
  const snapPos = getFloatCornerPos(nearestCorner);
404
- const springCfg = { type: "spring", stiffness: 400, damping: 30 };
405
- motionV.animate(x, snapPos.x, springCfg);
406
- motionV.animate(y, snapPos.y, springCfg);
428
+ if (noAnimation.value) {
429
+ x.set(snapPos.x);
430
+ y.set(snapPos.y);
431
+ } else {
432
+ const springCfg = { type: "spring", stiffness: 400, damping: 30 };
433
+ motionV.animate(x, snapPos.x, springCfg);
434
+ motionV.animate(y, snapPos.y, springCfg);
435
+ }
407
436
  };
408
437
  return vue.h(
409
438
  motionV.motion.div,
@@ -429,8 +458,8 @@ const GridItem = vue.defineComponent({
429
458
  x,
430
459
  y
431
460
  },
432
- whileDrag: { cursor: "grabbing", scale: 1.05, boxShadow: "0 8px 32px rgba(0,0,0,0.4)" },
433
- transition: { type: "spring", stiffness: 400, damping: 30 },
461
+ whileDrag: noAnimation.value ? { cursor: "grabbing" } : { cursor: "grabbing", scale: 1.05, boxShadow: "0 8px 32px rgba(0,0,0,0.4)" },
462
+ transition: noAnimation.value ? { duration: 0 } : { type: "spring", stiffness: 400, damping: 30 },
434
463
  "data-grid-index": props.index,
435
464
  "data-grid-float": true,
436
465
  onDragEnd: handleDragEnd
@@ -440,7 +469,7 @@ const GridItem = vue.defineComponent({
440
469
  }
441
470
  const itemWidth = dimensions.value.width;
442
471
  const itemHeight = dimensions.value.height;
443
- if (props.disableAnimation) {
472
+ if (noAnimation.value) {
444
473
  return vue.h(
445
474
  props.tag,
446
475
  {
@@ -457,18 +486,25 @@ const GridItem = vue.defineComponent({
457
486
  slots.default?.(slotProps.value)
458
487
  );
459
488
  }
489
+ const transition = noAnimation.value ? { duration: 0 } : {
490
+ type: "spring",
491
+ stiffness: springConfig.value.stiffness,
492
+ damping: springConfig.value.damping,
493
+ mass: springConfig.value.mass
494
+ };
460
495
  return vue.h(
461
496
  motionV.motion.div,
462
497
  {
463
498
  key: `grid-${props.index}`,
499
+ initial: { width: itemWidth, height: itemHeight },
500
+ animate: { width: itemWidth, height: itemHeight },
501
+ transition,
464
502
  style: {
465
503
  position: "absolute",
466
504
  top: 0,
467
505
  left: 0,
468
506
  x: gridX,
469
- y: gridY,
470
- width: `${itemWidth}px`,
471
- height: `${itemHeight}px`
507
+ y: gridY
472
508
  },
473
509
  "data-grid-index": props.index,
474
510
  "data-grid-main": isMain.value
@@ -575,7 +611,7 @@ const FloatingGridItem = vue.defineComponent({
575
611
  console.warn("FloatingGridItem must be used inside a GridContainer");
576
612
  return () => null;
577
613
  }
578
- const { dimensions } = context;
614
+ const { dimensions, disableAnimation: containerDisableAnimation } = context;
579
615
  const currentAnchor = vue.ref(props.anchor);
580
616
  const effectiveSize = vue.computed(() => {
581
617
  if (props.breakpoints && props.breakpoints.length > 0 && dimensions.value.width > 0) {
@@ -645,9 +681,14 @@ const FloatingGridItem = vue.defineComponent({
645
681
  if (isInitialized.value && w > 0 && h2 > 0 && newAnchor !== currentAnchor.value) {
646
682
  currentAnchor.value = newAnchor;
647
683
  const pos = getCornerPosition(newAnchor);
648
- const springCfg = { type: "spring", stiffness: 400, damping: 30 };
649
- motionV.animate(x, pos.x, springCfg);
650
- motionV.animate(y, pos.y, springCfg);
684
+ if (containerDisableAnimation.value) {
685
+ x.set(pos.x);
686
+ y.set(pos.y);
687
+ } else {
688
+ const springCfg = { type: "spring", stiffness: 400, damping: 30 };
689
+ motionV.animate(x, pos.x, springCfg);
690
+ motionV.animate(y, pos.y, springCfg);
691
+ }
651
692
  }
652
693
  }
653
694
  );
@@ -656,9 +697,14 @@ const FloatingGridItem = vue.defineComponent({
656
697
  () => {
657
698
  if (isInitialized.value && containerDimensions.value.width > 0 && containerDimensions.value.height > 0) {
658
699
  const pos = getCornerPosition(currentAnchor.value);
659
- const springCfg = { type: "spring", stiffness: 400, damping: 30 };
660
- motionV.animate(x, pos.x, springCfg);
661
- motionV.animate(y, pos.y, springCfg);
700
+ if (containerDisableAnimation) {
701
+ x.set(pos.x);
702
+ y.set(pos.y);
703
+ } else {
704
+ const springCfg = { type: "spring", stiffness: 400, damping: 30 };
705
+ motionV.animate(x, pos.x, springCfg);
706
+ motionV.animate(y, pos.y, springCfg);
707
+ }
662
708
  }
663
709
  }
664
710
  );
@@ -683,9 +729,14 @@ const FloatingGridItem = vue.defineComponent({
683
729
  currentAnchor.value = nearestCorner;
684
730
  emit("anchorChange", nearestCorner);
685
731
  const snapPos = getCornerPosition(nearestCorner);
686
- const springCfg = { type: "spring", stiffness: 400, damping: 30 };
687
- motionV.animate(x, snapPos.x, springCfg);
688
- motionV.animate(y, snapPos.y, springCfg);
732
+ if (containerDisableAnimation.value) {
733
+ x.set(snapPos.x);
734
+ y.set(snapPos.y);
735
+ } else {
736
+ const springCfg = { type: "spring", stiffness: 400, damping: 30 };
737
+ motionV.animate(x, snapPos.x, springCfg);
738
+ motionV.animate(y, snapPos.y, springCfg);
739
+ }
689
740
  };
690
741
  return vue.h(
691
742
  motionV.motion.div,
@@ -709,8 +760,8 @@ const FloatingGridItem = vue.defineComponent({
709
760
  x,
710
761
  y
711
762
  },
712
- whileDrag: { cursor: "grabbing", scale: 1.05, boxShadow: "0 8px 32px rgba(0,0,0,0.4)" },
713
- transition: { type: "spring", stiffness: 400, damping: 30 },
763
+ whileDrag: containerDisableAnimation.value ? { cursor: "grabbing" } : { cursor: "grabbing", scale: 1.05, boxShadow: "0 8px 32px rgba(0,0,0,0.4)" },
764
+ transition: containerDisableAnimation.value ? { duration: 0 } : { type: "spring", stiffness: 400, damping: 30 },
714
765
  onDragEnd: handleDragEnd
715
766
  },
716
767
  slots.default?.()
package/dist/index.d.cts CHANGED
@@ -20,20 +20,24 @@ declare function useMeetGrid(options: Ref<MeetGridOptions> | ComputedRef<MeetGri
20
20
  * Composable to get animation configuration for Motion
21
21
  */
22
22
  declare function useGridAnimation(preset?: SpringPreset): ComputedRef<{
23
- stiffness: 400;
24
- damping: 30;
23
+ stiffness: 800;
24
+ damping: 35;
25
+ mass: 0.5;
25
26
  type: "spring";
26
27
  } | {
27
- stiffness: 300;
28
- damping: 30;
28
+ stiffness: 200;
29
+ damping: 26;
30
+ mass: 1;
29
31
  type: "spring";
30
32
  } | {
31
- stiffness: 200;
32
- damping: 25;
33
+ stiffness: 60;
34
+ damping: 14;
35
+ mass: 1.8;
33
36
  type: "spring";
34
37
  } | {
35
- stiffness: 400;
36
- damping: 15;
38
+ stiffness: 500;
39
+ damping: 8;
40
+ mass: 0.6;
37
41
  type: "spring";
38
42
  }>;
39
43
  /**
@@ -48,8 +52,9 @@ declare function useGridItemPosition(grid: ComputedRef<MeetGridResult>, index: R
48
52
 
49
53
  interface GridContextValue {
50
54
  grid: ComputedRef<MeetGridResult>;
51
- springPreset: SpringPreset;
55
+ springPreset: Ref<SpringPreset>;
52
56
  dimensions: Ref<GridDimensions>;
57
+ disableAnimation: Ref<boolean>;
53
58
  }
54
59
  declare const GridContextKey: InjectionKey<GridContextValue>;
55
60
  declare const GridContainer: vue.DefineComponent<vue.ExtractPropTypes<{
@@ -170,6 +175,16 @@ declare const GridContainer: vue.DefineComponent<vue.ExtractPropTypes<{
170
175
  type: BooleanConstructor;
171
176
  default: boolean;
172
177
  };
178
+ /**
179
+ * Disable all animations globally.
180
+ * When true, all grid items and float items render without
181
+ * spring/transition animations. Items snap to positions instantly.
182
+ * @default false
183
+ */
184
+ disableAnimation: {
185
+ type: BooleanConstructor;
186
+ default: boolean;
187
+ };
173
188
  /** HTML tag to render */
174
189
  tag: {
175
190
  type: StringConstructor;
@@ -295,6 +310,16 @@ declare const GridContainer: vue.DefineComponent<vue.ExtractPropTypes<{
295
310
  type: BooleanConstructor;
296
311
  default: boolean;
297
312
  };
313
+ /**
314
+ * Disable all animations globally.
315
+ * When true, all grid items and float items render without
316
+ * spring/transition animations. Items snap to positions instantly.
317
+ * @default false
318
+ */
319
+ disableAnimation: {
320
+ type: BooleanConstructor;
321
+ default: boolean;
322
+ };
298
323
  /** HTML tag to render */
299
324
  tag: {
300
325
  type: StringConstructor;
@@ -318,6 +343,7 @@ declare const GridContainer: vue.DefineComponent<vue.ExtractPropTypes<{
318
343
  pipIndex: number;
319
344
  pinOnly: boolean;
320
345
  disableFloat: boolean;
346
+ disableAnimation: boolean;
321
347
  tag: string;
322
348
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
323
349
  declare const GridItem: vue.DefineComponent<vue.ExtractPropTypes<{
@@ -365,8 +391,8 @@ declare const GridItem: vue.DefineComponent<vue.ExtractPropTypes<{
365
391
  default: string;
366
392
  };
367
393
  }>> & Readonly<{}>, {
368
- tag: string;
369
394
  disableAnimation: boolean;
395
+ tag: string;
370
396
  itemAspectRatio: string;
371
397
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
372
398
  declare const GridOverlay: vue.DefineComponent<vue.ExtractPropTypes<{
package/dist/index.d.mts CHANGED
@@ -20,20 +20,24 @@ declare function useMeetGrid(options: Ref<MeetGridOptions> | ComputedRef<MeetGri
20
20
  * Composable to get animation configuration for Motion
21
21
  */
22
22
  declare function useGridAnimation(preset?: SpringPreset): ComputedRef<{
23
- stiffness: 400;
24
- damping: 30;
23
+ stiffness: 800;
24
+ damping: 35;
25
+ mass: 0.5;
25
26
  type: "spring";
26
27
  } | {
27
- stiffness: 300;
28
- damping: 30;
28
+ stiffness: 200;
29
+ damping: 26;
30
+ mass: 1;
29
31
  type: "spring";
30
32
  } | {
31
- stiffness: 200;
32
- damping: 25;
33
+ stiffness: 60;
34
+ damping: 14;
35
+ mass: 1.8;
33
36
  type: "spring";
34
37
  } | {
35
- stiffness: 400;
36
- damping: 15;
38
+ stiffness: 500;
39
+ damping: 8;
40
+ mass: 0.6;
37
41
  type: "spring";
38
42
  }>;
39
43
  /**
@@ -48,8 +52,9 @@ declare function useGridItemPosition(grid: ComputedRef<MeetGridResult>, index: R
48
52
 
49
53
  interface GridContextValue {
50
54
  grid: ComputedRef<MeetGridResult>;
51
- springPreset: SpringPreset;
55
+ springPreset: Ref<SpringPreset>;
52
56
  dimensions: Ref<GridDimensions>;
57
+ disableAnimation: Ref<boolean>;
53
58
  }
54
59
  declare const GridContextKey: InjectionKey<GridContextValue>;
55
60
  declare const GridContainer: vue.DefineComponent<vue.ExtractPropTypes<{
@@ -170,6 +175,16 @@ declare const GridContainer: vue.DefineComponent<vue.ExtractPropTypes<{
170
175
  type: BooleanConstructor;
171
176
  default: boolean;
172
177
  };
178
+ /**
179
+ * Disable all animations globally.
180
+ * When true, all grid items and float items render without
181
+ * spring/transition animations. Items snap to positions instantly.
182
+ * @default false
183
+ */
184
+ disableAnimation: {
185
+ type: BooleanConstructor;
186
+ default: boolean;
187
+ };
173
188
  /** HTML tag to render */
174
189
  tag: {
175
190
  type: StringConstructor;
@@ -295,6 +310,16 @@ declare const GridContainer: vue.DefineComponent<vue.ExtractPropTypes<{
295
310
  type: BooleanConstructor;
296
311
  default: boolean;
297
312
  };
313
+ /**
314
+ * Disable all animations globally.
315
+ * When true, all grid items and float items render without
316
+ * spring/transition animations. Items snap to positions instantly.
317
+ * @default false
318
+ */
319
+ disableAnimation: {
320
+ type: BooleanConstructor;
321
+ default: boolean;
322
+ };
298
323
  /** HTML tag to render */
299
324
  tag: {
300
325
  type: StringConstructor;
@@ -318,6 +343,7 @@ declare const GridContainer: vue.DefineComponent<vue.ExtractPropTypes<{
318
343
  pipIndex: number;
319
344
  pinOnly: boolean;
320
345
  disableFloat: boolean;
346
+ disableAnimation: boolean;
321
347
  tag: string;
322
348
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
323
349
  declare const GridItem: vue.DefineComponent<vue.ExtractPropTypes<{
@@ -365,8 +391,8 @@ declare const GridItem: vue.DefineComponent<vue.ExtractPropTypes<{
365
391
  default: string;
366
392
  };
367
393
  }>> & Readonly<{}>, {
368
- tag: string;
369
394
  disableAnimation: boolean;
395
+ tag: string;
370
396
  itemAspectRatio: string;
371
397
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
372
398
  declare const GridOverlay: vue.DefineComponent<vue.ExtractPropTypes<{
package/dist/index.d.ts CHANGED
@@ -20,20 +20,24 @@ declare function useMeetGrid(options: Ref<MeetGridOptions> | ComputedRef<MeetGri
20
20
  * Composable to get animation configuration for Motion
21
21
  */
22
22
  declare function useGridAnimation(preset?: SpringPreset): ComputedRef<{
23
- stiffness: 400;
24
- damping: 30;
23
+ stiffness: 800;
24
+ damping: 35;
25
+ mass: 0.5;
25
26
  type: "spring";
26
27
  } | {
27
- stiffness: 300;
28
- damping: 30;
28
+ stiffness: 200;
29
+ damping: 26;
30
+ mass: 1;
29
31
  type: "spring";
30
32
  } | {
31
- stiffness: 200;
32
- damping: 25;
33
+ stiffness: 60;
34
+ damping: 14;
35
+ mass: 1.8;
33
36
  type: "spring";
34
37
  } | {
35
- stiffness: 400;
36
- damping: 15;
38
+ stiffness: 500;
39
+ damping: 8;
40
+ mass: 0.6;
37
41
  type: "spring";
38
42
  }>;
39
43
  /**
@@ -48,8 +52,9 @@ declare function useGridItemPosition(grid: ComputedRef<MeetGridResult>, index: R
48
52
 
49
53
  interface GridContextValue {
50
54
  grid: ComputedRef<MeetGridResult>;
51
- springPreset: SpringPreset;
55
+ springPreset: Ref<SpringPreset>;
52
56
  dimensions: Ref<GridDimensions>;
57
+ disableAnimation: Ref<boolean>;
53
58
  }
54
59
  declare const GridContextKey: InjectionKey<GridContextValue>;
55
60
  declare const GridContainer: vue.DefineComponent<vue.ExtractPropTypes<{
@@ -170,6 +175,16 @@ declare const GridContainer: vue.DefineComponent<vue.ExtractPropTypes<{
170
175
  type: BooleanConstructor;
171
176
  default: boolean;
172
177
  };
178
+ /**
179
+ * Disable all animations globally.
180
+ * When true, all grid items and float items render without
181
+ * spring/transition animations. Items snap to positions instantly.
182
+ * @default false
183
+ */
184
+ disableAnimation: {
185
+ type: BooleanConstructor;
186
+ default: boolean;
187
+ };
173
188
  /** HTML tag to render */
174
189
  tag: {
175
190
  type: StringConstructor;
@@ -295,6 +310,16 @@ declare const GridContainer: vue.DefineComponent<vue.ExtractPropTypes<{
295
310
  type: BooleanConstructor;
296
311
  default: boolean;
297
312
  };
313
+ /**
314
+ * Disable all animations globally.
315
+ * When true, all grid items and float items render without
316
+ * spring/transition animations. Items snap to positions instantly.
317
+ * @default false
318
+ */
319
+ disableAnimation: {
320
+ type: BooleanConstructor;
321
+ default: boolean;
322
+ };
298
323
  /** HTML tag to render */
299
324
  tag: {
300
325
  type: StringConstructor;
@@ -318,6 +343,7 @@ declare const GridContainer: vue.DefineComponent<vue.ExtractPropTypes<{
318
343
  pipIndex: number;
319
344
  pinOnly: boolean;
320
345
  disableFloat: boolean;
346
+ disableAnimation: boolean;
321
347
  tag: string;
322
348
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
323
349
  declare const GridItem: vue.DefineComponent<vue.ExtractPropTypes<{
@@ -365,8 +391,8 @@ declare const GridItem: vue.DefineComponent<vue.ExtractPropTypes<{
365
391
  default: string;
366
392
  };
367
393
  }>> & Readonly<{}>, {
368
- tag: string;
369
394
  disableAnimation: boolean;
395
+ tag: string;
370
396
  itemAspectRatio: string;
371
397
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
372
398
  declare const GridOverlay: vue.DefineComponent<vue.ExtractPropTypes<{
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createMeetGrid, getSpringConfig, resolveFloatSize } from '@thangdevalone/meeting-grid-layout-core';
2
2
  export { createGrid, createGridItemPositioner, createMeetGrid, getAspectRatio, getGridItemDimensions, getSpringConfig, springPresets } from '@thangdevalone/meeting-grid-layout-core';
3
3
  import { useResizeObserver } from '@vueuse/core';
4
- import { ref, onMounted, computed, defineComponent, provide, h, inject, watch } from 'vue';
4
+ import { ref, onMounted, computed, defineComponent, provide, toRef, h, inject, watch } from 'vue';
5
5
  import { useMotionValue, animate, motion } from 'motion-v';
6
6
 
7
7
  function useGridDimensions(elementRef) {
@@ -172,6 +172,16 @@ const GridContainer = defineComponent({
172
172
  type: Boolean,
173
173
  default: false
174
174
  },
175
+ /**
176
+ * Disable all animations globally.
177
+ * When true, all grid items and float items render without
178
+ * spring/transition animations. Items snap to positions instantly.
179
+ * @default false
180
+ */
181
+ disableAnimation: {
182
+ type: Boolean,
183
+ default: false
184
+ },
175
185
  /** HTML tag to render */
176
186
  tag: {
177
187
  type: String,
@@ -204,8 +214,9 @@ const GridContainer = defineComponent({
204
214
  const grid = useMeetGrid(gridOptions);
205
215
  provide(GridContextKey, {
206
216
  grid,
207
- springPreset: props.springPreset,
208
- dimensions
217
+ springPreset: toRef(props, "springPreset"),
218
+ dimensions,
219
+ disableAnimation: toRef(props, "disableAnimation")
209
220
  });
210
221
  return () => h(
211
222
  props.tag,
@@ -252,7 +263,8 @@ const GridItem = defineComponent({
252
263
  console.warn("GridItem must be used inside a GridContainer");
253
264
  return () => null;
254
265
  }
255
- const { grid, springPreset, dimensions: containerDimensions } = context;
266
+ const { grid, springPreset, dimensions: containerDimensions, disableAnimation: containerDisableAnimation } = context;
267
+ const noAnimation = computed(() => containerDisableAnimation.value || props.disableAnimation);
256
268
  const position = computed(() => grid.value.getPosition(props.index));
257
269
  const dimensions = computed(() => grid.value.getItemDimensions(props.index));
258
270
  const contentDimensions = computed(
@@ -330,9 +342,14 @@ const GridItem = defineComponent({
330
342
  ([, w, h2]) => {
331
343
  if (isFloat.value && floatInitialized.value && w > 0 && h2 > 0) {
332
344
  const pos = getFloatCornerPos(floatAnchor.value);
333
- const springCfg = { type: "spring", stiffness: 400, damping: 30 };
334
- animate(x, pos.x, springCfg);
335
- animate(y, pos.y, springCfg);
345
+ if (noAnimation.value) {
346
+ x.set(pos.x);
347
+ y.set(pos.y);
348
+ } else {
349
+ const springCfg = { type: "spring", stiffness: 400, damping: 30 };
350
+ animate(x, pos.x, springCfg);
351
+ animate(y, pos.y, springCfg);
352
+ }
336
353
  }
337
354
  }
338
355
  );
@@ -341,7 +358,7 @@ const GridItem = defineComponent({
341
358
  return props.index === lastVisibleOthersIndex;
342
359
  });
343
360
  const hiddenCount = computed(() => grid.value.hiddenCount);
344
- const springConfig = getSpringConfig(springPreset);
361
+ const springConfig = computed(() => getSpringConfig(springPreset.value));
345
362
  const gridX = useMotionValue(0);
346
363
  const gridY = useMotionValue(0);
347
364
  const gridAnimReady = ref(false);
@@ -350,7 +367,10 @@ const GridItem = defineComponent({
350
367
  () => position.value.top,
351
368
  () => position.value.left,
352
369
  isFloat,
353
- isHidden
370
+ isHidden,
371
+ () => springConfig.value.stiffness,
372
+ () => springConfig.value.damping,
373
+ () => springConfig.value.mass
354
374
  ],
355
375
  ([, , floating, hidden]) => {
356
376
  if (floating || hidden) {
@@ -362,11 +382,15 @@ const GridItem = defineComponent({
362
382
  gridX.set(pos.left);
363
383
  gridY.set(pos.top);
364
384
  gridAnimReady.value = true;
385
+ } else if (noAnimation.value) {
386
+ gridX.set(pos.left);
387
+ gridY.set(pos.top);
365
388
  } else {
366
389
  const cfg = {
367
390
  type: "spring",
368
- stiffness: springConfig.stiffness,
369
- damping: springConfig.damping
391
+ stiffness: springConfig.value.stiffness,
392
+ damping: springConfig.value.damping,
393
+ mass: springConfig.value.mass
370
394
  };
371
395
  animate(gridX, pos.left, cfg);
372
396
  animate(gridY, pos.top, cfg);
@@ -400,9 +424,14 @@ const GridItem = defineComponent({
400
424
  const nearestCorner = findFloatNearestCorner(currentX, currentY);
401
425
  floatAnchor.value = nearestCorner;
402
426
  const snapPos = getFloatCornerPos(nearestCorner);
403
- const springCfg = { type: "spring", stiffness: 400, damping: 30 };
404
- animate(x, snapPos.x, springCfg);
405
- animate(y, snapPos.y, springCfg);
427
+ if (noAnimation.value) {
428
+ x.set(snapPos.x);
429
+ y.set(snapPos.y);
430
+ } else {
431
+ const springCfg = { type: "spring", stiffness: 400, damping: 30 };
432
+ animate(x, snapPos.x, springCfg);
433
+ animate(y, snapPos.y, springCfg);
434
+ }
406
435
  };
407
436
  return h(
408
437
  motion.div,
@@ -428,8 +457,8 @@ const GridItem = defineComponent({
428
457
  x,
429
458
  y
430
459
  },
431
- whileDrag: { cursor: "grabbing", scale: 1.05, boxShadow: "0 8px 32px rgba(0,0,0,0.4)" },
432
- transition: { type: "spring", stiffness: 400, damping: 30 },
460
+ whileDrag: noAnimation.value ? { cursor: "grabbing" } : { cursor: "grabbing", scale: 1.05, boxShadow: "0 8px 32px rgba(0,0,0,0.4)" },
461
+ transition: noAnimation.value ? { duration: 0 } : { type: "spring", stiffness: 400, damping: 30 },
433
462
  "data-grid-index": props.index,
434
463
  "data-grid-float": true,
435
464
  onDragEnd: handleDragEnd
@@ -439,7 +468,7 @@ const GridItem = defineComponent({
439
468
  }
440
469
  const itemWidth = dimensions.value.width;
441
470
  const itemHeight = dimensions.value.height;
442
- if (props.disableAnimation) {
471
+ if (noAnimation.value) {
443
472
  return h(
444
473
  props.tag,
445
474
  {
@@ -456,18 +485,25 @@ const GridItem = defineComponent({
456
485
  slots.default?.(slotProps.value)
457
486
  );
458
487
  }
488
+ const transition = noAnimation.value ? { duration: 0 } : {
489
+ type: "spring",
490
+ stiffness: springConfig.value.stiffness,
491
+ damping: springConfig.value.damping,
492
+ mass: springConfig.value.mass
493
+ };
459
494
  return h(
460
495
  motion.div,
461
496
  {
462
497
  key: `grid-${props.index}`,
498
+ initial: { width: itemWidth, height: itemHeight },
499
+ animate: { width: itemWidth, height: itemHeight },
500
+ transition,
463
501
  style: {
464
502
  position: "absolute",
465
503
  top: 0,
466
504
  left: 0,
467
505
  x: gridX,
468
- y: gridY,
469
- width: `${itemWidth}px`,
470
- height: `${itemHeight}px`
506
+ y: gridY
471
507
  },
472
508
  "data-grid-index": props.index,
473
509
  "data-grid-main": isMain.value
@@ -574,7 +610,7 @@ const FloatingGridItem = defineComponent({
574
610
  console.warn("FloatingGridItem must be used inside a GridContainer");
575
611
  return () => null;
576
612
  }
577
- const { dimensions } = context;
613
+ const { dimensions, disableAnimation: containerDisableAnimation } = context;
578
614
  const currentAnchor = ref(props.anchor);
579
615
  const effectiveSize = computed(() => {
580
616
  if (props.breakpoints && props.breakpoints.length > 0 && dimensions.value.width > 0) {
@@ -644,9 +680,14 @@ const FloatingGridItem = defineComponent({
644
680
  if (isInitialized.value && w > 0 && h2 > 0 && newAnchor !== currentAnchor.value) {
645
681
  currentAnchor.value = newAnchor;
646
682
  const pos = getCornerPosition(newAnchor);
647
- const springCfg = { type: "spring", stiffness: 400, damping: 30 };
648
- animate(x, pos.x, springCfg);
649
- animate(y, pos.y, springCfg);
683
+ if (containerDisableAnimation.value) {
684
+ x.set(pos.x);
685
+ y.set(pos.y);
686
+ } else {
687
+ const springCfg = { type: "spring", stiffness: 400, damping: 30 };
688
+ animate(x, pos.x, springCfg);
689
+ animate(y, pos.y, springCfg);
690
+ }
650
691
  }
651
692
  }
652
693
  );
@@ -655,9 +696,14 @@ const FloatingGridItem = defineComponent({
655
696
  () => {
656
697
  if (isInitialized.value && containerDimensions.value.width > 0 && containerDimensions.value.height > 0) {
657
698
  const pos = getCornerPosition(currentAnchor.value);
658
- const springCfg = { type: "spring", stiffness: 400, damping: 30 };
659
- animate(x, pos.x, springCfg);
660
- animate(y, pos.y, springCfg);
699
+ if (containerDisableAnimation) {
700
+ x.set(pos.x);
701
+ y.set(pos.y);
702
+ } else {
703
+ const springCfg = { type: "spring", stiffness: 400, damping: 30 };
704
+ animate(x, pos.x, springCfg);
705
+ animate(y, pos.y, springCfg);
706
+ }
661
707
  }
662
708
  }
663
709
  );
@@ -682,9 +728,14 @@ const FloatingGridItem = defineComponent({
682
728
  currentAnchor.value = nearestCorner;
683
729
  emit("anchorChange", nearestCorner);
684
730
  const snapPos = getCornerPosition(nearestCorner);
685
- const springCfg = { type: "spring", stiffness: 400, damping: 30 };
686
- animate(x, snapPos.x, springCfg);
687
- animate(y, snapPos.y, springCfg);
731
+ if (containerDisableAnimation.value) {
732
+ x.set(snapPos.x);
733
+ y.set(snapPos.y);
734
+ } else {
735
+ const springCfg = { type: "spring", stiffness: 400, damping: 30 };
736
+ animate(x, snapPos.x, springCfg);
737
+ animate(y, snapPos.y, springCfg);
738
+ }
688
739
  };
689
740
  return h(
690
741
  motion.div,
@@ -708,8 +759,8 @@ const FloatingGridItem = defineComponent({
708
759
  x,
709
760
  y
710
761
  },
711
- whileDrag: { cursor: "grabbing", scale: 1.05, boxShadow: "0 8px 32px rgba(0,0,0,0.4)" },
712
- transition: { type: "spring", stiffness: 400, damping: 30 },
762
+ whileDrag: containerDisableAnimation.value ? { cursor: "grabbing" } : { cursor: "grabbing", scale: 1.05, boxShadow: "0 8px 32px rgba(0,0,0,0.4)" },
763
+ transition: containerDisableAnimation.value ? { duration: 0 } : { type: "spring", stiffness: 400, damping: 30 },
713
764
  onDragEnd: handleDragEnd
714
765
  },
715
766
  slots.default?.()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thangdevalone/meeting-grid-layout-vue",
3
- "version": "1.5.7",
3
+ "version": "1.5.9",
4
4
  "description": "Vue 3 integration for meeting-grid-layout with Motion animations",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -43,7 +43,7 @@
43
43
  "dependencies": {
44
44
  "@vueuse/core": "^10.7.0",
45
45
  "motion-v": "^1.0.0",
46
- "@thangdevalone/meeting-grid-layout-core": "1.5.7"
46
+ "@thangdevalone/meeting-grid-layout-core": "1.5.9"
47
47
  },
48
48
  "devDependencies": {
49
49
  "vue": "^3.4.0",