@maas/vue-equipment 0.16.2 → 0.16.3

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.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@maas/vue-equipment/nuxt",
3
3
  "configKey": "vueEquipment",
4
- "version": "0.16.1"
4
+ "version": "0.16.2"
5
5
  }
@@ -26,7 +26,13 @@ export function useDrawerDrag(args) {
26
26
  } = args;
27
27
  const elRect = ref(void 0);
28
28
  const wrapperRect = ref(void 0);
29
- const { findClosestSnapPoint, mapSnapPoint, drawerHeight, drawerWidth } = useDrawerSnap({
29
+ const {
30
+ findClosestSnapPoint,
31
+ mapSnapPoint,
32
+ snapPointsMap,
33
+ drawerHeight,
34
+ drawerWidth
35
+ } = useDrawerSnap({
30
36
  wrapperRect,
31
37
  snapPoints,
32
38
  canClose,
@@ -269,6 +275,8 @@ export function useDrawerDrag(args) {
269
275
  }
270
276
  }
271
277
  async function interpolateDragged(target) {
278
+ const snapPoint2 = snapPointsMap.value[target];
279
+ useDrawerEmitter().emit("beforeSnap", { id: toValue(id), snapPoint: snapPoint2 });
272
280
  switch (position) {
273
281
  case "bottom":
274
282
  case "top":
@@ -279,6 +287,12 @@ export function useDrawerDrag(args) {
279
287
  duration: 300,
280
288
  callback: (value) => {
281
289
  draggedY.value = value;
290
+ if (draggedY.value === target) {
291
+ useDrawerEmitter().emit("beforeSnap", {
292
+ id: toValue(id),
293
+ snapPoint: snapPoint2
294
+ });
295
+ }
282
296
  }
283
297
  });
284
298
  break;
@@ -291,6 +305,12 @@ export function useDrawerDrag(args) {
291
305
  duration: 300,
292
306
  callback: (value) => {
293
307
  draggedX.value = value;
308
+ if (draggedX.value === target) {
309
+ useDrawerEmitter().emit("beforeSnap", {
310
+ id: toValue(id),
311
+ snapPoint: snapPoint2
312
+ });
313
+ }
294
314
  }
295
315
  });
296
316
  break;
@@ -16,6 +16,7 @@ type FindClosestSnapPointArgs = {
16
16
  export declare function useDrawerSnap(args: UseDrawerSnapArgs): {
17
17
  findClosestSnapPoint: (args: FindClosestSnapPointArgs) => Promise<number | undefined>;
18
18
  mapSnapPoint: (snapPoint: SnapPoint) => number | undefined;
19
+ snapPointsMap: import("vue").ComputedRef<Record<number, SnapPoint>>;
19
20
  drawerHeight: import("vue").ComputedRef<number>;
20
21
  drawerWidth: import("vue").ComputedRef<number>;
21
22
  };
@@ -12,6 +12,17 @@ export function useDrawerSnap(args) {
12
12
  ).sort((a, b) => a - b);
13
13
  return filtered;
14
14
  });
15
+ const snapPointsMap = computed(() => {
16
+ const extended = toValue(canClose) ? [...toValue(snapPoints), 0] : toValue(snapPoints);
17
+ const mapped = extended.reduce((acc, current) => {
18
+ const key = mapSnapPoint(current);
19
+ if (key || key === 0) {
20
+ acc[key] = current;
21
+ }
22
+ return acc;
23
+ }, {});
24
+ return mapped;
25
+ });
15
26
  const drawerHeight = computed(() => {
16
27
  if (toValue(wrapperRect) === void 0) {
17
28
  return 0;
@@ -134,5 +145,11 @@ export function useDrawerSnap(args) {
134
145
  }
135
146
  return closest;
136
147
  }
137
- return { findClosestSnapPoint, mapSnapPoint, drawerHeight, drawerWidth };
148
+ return {
149
+ findClosestSnapPoint,
150
+ mapSnapPoint,
151
+ snapPointsMap,
152
+ drawerHeight,
153
+ drawerWidth
154
+ };
138
155
  }
@@ -34,4 +34,12 @@ export type DrawerEvents = {
34
34
  beforeLeave: string;
35
35
  leave: string;
36
36
  afterLeave: string;
37
+ beforeSnap: {
38
+ id: string;
39
+ snapPoint: SnapPoint;
40
+ };
41
+ afterSnap: {
42
+ id: string;
43
+ snapPoint: SnapPoint;
44
+ };
37
45
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maas/vue-equipment",
3
3
  "description": "A magic collection of Vue composables, plugins, components and directives",
4
- "version": "0.16.2",
4
+ "version": "0.16.3",
5
5
  "author": "Robin Scholz <https://github.com/robinscholz>, Christoph Jeworutzki <https://github.com/ChristophJeworutzki>",
6
6
  "devDependencies": {
7
7
  "@antfu/ni": "^0.21.12",