@maas/vue-equipment 1.0.0-beta.43 → 1.0.0-beta.45
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/composables/useScrollLockPadding/index.js +1 -0
- package/dist/composables/useScrollLockPadding/index.js.map +1 -1
- package/dist/nuxt/module.json +1 -1
- package/dist/nuxt/module.mjs +1 -1
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionProvider.vue +2 -5
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionState.d.ts +2 -3
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionState.mjs +38 -11
- package/dist/plugins/MagicAccordion/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicCommand/src/components/MagicCommandItem.d.vue.ts +2 -2
- package/dist/plugins/MagicCommand/src/components/MagicCommandItem.vue.d.ts +2 -2
- package/dist/plugins/MagicCommand/src/components/MagicCommandProvider.vue +2 -5
- package/dist/plugins/MagicCommand/src/components/MagicCommandRenderer.vue +1 -0
- package/dist/plugins/MagicCommand/src/composables/private/useCommandState.d.ts +2 -3
- package/dist/plugins/MagicCommand/src/composables/private/useCommandState.mjs +36 -11
- package/dist/plugins/MagicCommand/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicCookie/src/composables/private/useCookieState.d.ts +2 -3
- package/dist/plugins/MagicCookie/src/composables/private/useCookieState.mjs +35 -12
- package/dist/plugins/MagicCookie/src/composables/useMagicCookie.mjs +6 -1
- package/dist/plugins/MagicCookie/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableDrag.mjs +28 -11
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableSnap.mjs +11 -1
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableState.d.ts +1 -1
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableState.mjs +41 -11
- package/dist/plugins/MagicDraggable/src/composables/useMagicDraggable.mjs +2 -1
- package/dist/plugins/MagicDraggable/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.d.vue.ts +2 -2
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue +11 -3
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue.d.ts +2 -2
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDrag.d.ts +2 -0
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDrag.mjs +184 -29
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerState.d.ts +2 -3
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerState.mjs +35 -10
- package/dist/plugins/MagicDrawer/src/composables/useMagicDrawer.mjs +2 -1
- package/dist/plugins/MagicDrawer/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicEmitter/src/composables/useMagicEmitter.mjs +10 -5
- package/dist/plugins/MagicMarquee/src/components/MagicMarquee.vue +2 -5
- package/dist/plugins/MagicMarquee/src/composables/private/useMarqueeState.d.ts +2 -3
- package/dist/plugins/MagicMarquee/src/composables/private/useMarqueeState.mjs +36 -11
- package/dist/plugins/MagicMarquee/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicMenu/src/components/MagicMenuItem.d.vue.ts +2 -2
- package/dist/plugins/MagicMenu/src/components/MagicMenuItem.vue.d.ts +2 -2
- package/dist/plugins/MagicMenu/src/components/MagicMenuProvider.vue +2 -6
- package/dist/plugins/MagicMenu/src/composables/private/useMenuCursor.mjs +13 -1
- package/dist/plugins/MagicMenu/src/composables/private/useMenuState.d.ts +2 -3
- package/dist/plugins/MagicMenu/src/composables/private/useMenuState.mjs +32 -12
- package/dist/plugins/MagicMenu/src/composables/private/useMenuTrigger.mjs +1 -1
- package/dist/plugins/MagicMenu/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicModal/src/composables/private/useModalState.d.ts +6 -0
- package/dist/plugins/MagicModal/src/composables/private/useModalState.mjs +58 -0
- package/dist/plugins/MagicModal/src/composables/private/useModalStore.d.ts +1 -5
- package/dist/plugins/MagicModal/src/composables/private/useModalStore.mjs +1 -15
- package/dist/plugins/MagicModal/src/composables/useMagicModal.mjs +7 -6
- package/dist/plugins/MagicModal/src/types/index.d.ts +5 -0
- package/dist/plugins/MagicNoise/src/components/MagicNoise.vue +14 -2
- package/dist/plugins/MagicPie/src/components/MagicPie.vue +12 -6
- package/dist/plugins/MagicPie/src/composables/private/usePieState.d.ts +1 -1
- package/dist/plugins/MagicPie/src/composables/private/usePieState.mjs +33 -12
- package/dist/plugins/MagicPie/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudio.vue +9 -6
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudioControls.vue +4 -8
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerMuxPopover.vue +8 -1
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerProvider.vue +2 -11
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideo.vue +10 -6
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideoControls.vue +4 -8
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerControlsApi.d.ts +0 -1
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerControlsApi.mjs +20 -9
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerEmitter.mjs +124 -75
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerMediaApi.mjs +100 -32
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerRuntime.d.ts +0 -1
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerRuntime.mjs +33 -13
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerState.d.ts +2 -3
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerState.mjs +35 -10
- package/dist/plugins/MagicPlayer/src/composables/useMagicPlayer.d.ts +0 -2
- package/dist/plugins/MagicPlayer/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicScroll/src/components/MagicScrollCollision.vue +2 -2
- package/dist/plugins/MagicScroll/src/components/MagicScrollMotion.vue +13 -1
- package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue +9 -5
- package/dist/plugins/MagicScroll/src/composables/private/useCollisionDetection.mjs +2 -1
- package/dist/plugins/MagicToast/src/components/MagicToastProvider.vue +2 -11
- package/dist/plugins/MagicToast/src/components/MagicToastView.vue +1 -0
- package/dist/plugins/MagicToast/src/composables/private/useToastDrag.mjs +13 -1
- package/dist/plugins/MagicToast/src/composables/private/useToastState.d.ts +2 -3
- package/dist/plugins/MagicToast/src/composables/private/useToastState.mjs +35 -12
- package/dist/plugins/MagicToast/src/types/index.d.ts +1 -0
- package/dist/utils/index.d.ts +8 -1
- package/dist/utils/index.js +31 -0
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/plugins/MagicError/src/MagicError.d.ts +0 -0
- package/dist/plugins/MagicError/src/MagicError.mjs +0 -0
|
@@ -14,11 +14,11 @@ interface MagicDrawerProps {
|
|
|
14
14
|
id: MaybeRef<string>;
|
|
15
15
|
options?: MagicDrawerOptions;
|
|
16
16
|
}
|
|
17
|
-
declare var __VLS_11: {},
|
|
17
|
+
declare var __VLS_11: {}, __VLS_38: {};
|
|
18
18
|
type __VLS_Slots = {} & {
|
|
19
19
|
backdrop?: (props: typeof __VLS_11) => any;
|
|
20
20
|
} & {
|
|
21
|
-
default?: (props: typeof
|
|
21
|
+
default?: (props: typeof __VLS_38) => any;
|
|
22
22
|
};
|
|
23
23
|
declare const __VLS_base: import("vue").DefineComponent<MagicDrawerProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<MagicDrawerProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
24
24
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
class="magic-drawer"
|
|
10
10
|
:data-id="mappedId"
|
|
11
11
|
:data-dragging="dragging"
|
|
12
|
+
:data-dragged="hasDragged"
|
|
12
13
|
:data-wheeling="wheeling"
|
|
13
14
|
:data-disabled="disabled"
|
|
14
15
|
:data-position="mappedOptions.position"
|
|
@@ -45,6 +46,7 @@
|
|
|
45
46
|
class="magic-drawer__drag"
|
|
46
47
|
:style="style"
|
|
47
48
|
@pointerdown="guardedPointerdown"
|
|
49
|
+
@touchstart="guardedTouchstart"
|
|
48
50
|
@click="guardedClick"
|
|
49
51
|
>
|
|
50
52
|
<slot />
|
|
@@ -135,7 +137,7 @@ const disabled = computed(() => {
|
|
|
135
137
|
return options.disabled;
|
|
136
138
|
}
|
|
137
139
|
});
|
|
138
|
-
const { onPointerdown, onClick, style, hasDragged } = useDrawerDrag({
|
|
140
|
+
const { onPointerdown, onTouchstart, onClick, style, hasDragged } = useDrawerDrag({
|
|
139
141
|
id,
|
|
140
142
|
elRef,
|
|
141
143
|
wrapperRef,
|
|
@@ -154,7 +156,7 @@ const { initializeWheelListener, destroyWheelListener } = useDrawerWheel({
|
|
|
154
156
|
position,
|
|
155
157
|
disabled
|
|
156
158
|
});
|
|
157
|
-
const { initializeState
|
|
159
|
+
const { initializeState } = useDrawerState(id);
|
|
158
160
|
const state = initializeState();
|
|
159
161
|
const { dragging, wheeling } = toRefs(state);
|
|
160
162
|
const innerActive = shallowRef(false);
|
|
@@ -226,6 +228,11 @@ function guardedPointerdown(event) {
|
|
|
226
228
|
onPointerdown(event);
|
|
227
229
|
}
|
|
228
230
|
}
|
|
231
|
+
function guardedTouchstart(event) {
|
|
232
|
+
if (!disabled.value) {
|
|
233
|
+
onTouchstart(event);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
229
236
|
function guardedClick(event) {
|
|
230
237
|
if (!disabled.value) {
|
|
231
238
|
onClick(event);
|
|
@@ -282,7 +289,6 @@ onUnmounted(() => {
|
|
|
282
289
|
if (!mappedOptions.preventZoom) {
|
|
283
290
|
resetMetaViewport();
|
|
284
291
|
}
|
|
285
|
-
deleteState();
|
|
286
292
|
});
|
|
287
293
|
</script>
|
|
288
294
|
|
|
@@ -446,6 +452,8 @@ dialog.magic-drawer__drag::backdrop {
|
|
|
446
452
|
|
|
447
453
|
.magic-drawer__drag > * {
|
|
448
454
|
padding: var(--magic-drawer-padding);
|
|
455
|
+
-webkit-overflow-scrolling: touch;
|
|
456
|
+
scroll-behavior: smooth;
|
|
449
457
|
}
|
|
450
458
|
|
|
451
459
|
.magic-drawer__overlay {
|
|
@@ -14,11 +14,11 @@ interface MagicDrawerProps {
|
|
|
14
14
|
id: MaybeRef<string>;
|
|
15
15
|
options?: MagicDrawerOptions;
|
|
16
16
|
}
|
|
17
|
-
declare var __VLS_11: {},
|
|
17
|
+
declare var __VLS_11: {}, __VLS_38: {};
|
|
18
18
|
type __VLS_Slots = {} & {
|
|
19
19
|
backdrop?: (props: typeof __VLS_11) => any;
|
|
20
20
|
} & {
|
|
21
|
-
default?: (props: typeof
|
|
21
|
+
default?: (props: typeof __VLS_38) => any;
|
|
22
22
|
};
|
|
23
23
|
declare const __VLS_base: import("vue").DefineComponent<MagicDrawerProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<MagicDrawerProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
24
24
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -15,6 +15,8 @@ type UseDrawerDragArgs = {
|
|
|
15
15
|
};
|
|
16
16
|
export declare function useDrawerDrag(args: UseDrawerDragArgs): {
|
|
17
17
|
onPointerdown: (e: PointerEvent) => void;
|
|
18
|
+
onTouchstart: (e: TouchEvent) => void;
|
|
19
|
+
onTouchmove: (e: TouchEvent) => void;
|
|
18
20
|
onClick: (e: MouseEvent) => void;
|
|
19
21
|
style: import("vue").ComputedRef<string>;
|
|
20
22
|
hasDragged: import("vue").ComputedRef<boolean>;
|
|
@@ -2,10 +2,11 @@ import {
|
|
|
2
2
|
computed,
|
|
3
3
|
onMounted,
|
|
4
4
|
watch,
|
|
5
|
-
onBeforeUnmount,
|
|
6
5
|
toValue,
|
|
7
6
|
toRefs,
|
|
8
|
-
nextTick
|
|
7
|
+
nextTick,
|
|
8
|
+
onScopeDispose,
|
|
9
|
+
markRaw
|
|
9
10
|
} from "vue";
|
|
10
11
|
import {
|
|
11
12
|
useEventListener,
|
|
@@ -17,6 +18,7 @@ import {
|
|
|
17
18
|
import {
|
|
18
19
|
guardedReleasePointerCapture,
|
|
19
20
|
guardedSetPointerCapture,
|
|
21
|
+
isAndroid,
|
|
20
22
|
isIOS,
|
|
21
23
|
isWithinRange
|
|
22
24
|
} from "@maas/vue-equipment/utils";
|
|
@@ -72,8 +74,12 @@ export function useDrawerDrag(args) {
|
|
|
72
74
|
let pointerdownTarget = void 0;
|
|
73
75
|
let cancelPointerup = void 0;
|
|
74
76
|
let cancelPointermove = void 0;
|
|
77
|
+
let cancelPointercancel = void 0;
|
|
78
|
+
let cancelTouchmove = void 0;
|
|
75
79
|
let cancelTouchend = void 0;
|
|
80
|
+
let cancelTouchcancel = void 0;
|
|
76
81
|
let scrollLock = void 0;
|
|
82
|
+
let resizeObserverEl = null;
|
|
77
83
|
const hasDragged = computed(() => {
|
|
78
84
|
const hasDraggedX = !isWithinRange({
|
|
79
85
|
input: draggedX.value,
|
|
@@ -121,8 +127,10 @@ export function useDrawerDrag(args) {
|
|
|
121
127
|
const { clamp } = useDrawerUtils();
|
|
122
128
|
const emitter = useMagicEmitter();
|
|
123
129
|
async function getSizes() {
|
|
124
|
-
|
|
125
|
-
|
|
130
|
+
const el = unrefElement(elRef);
|
|
131
|
+
const wrapper = unrefElement(wrapperRef);
|
|
132
|
+
elRect.value = el ? markRaw(el.getBoundingClientRect()) : void 0;
|
|
133
|
+
wrapperRect.value = wrapper ? markRaw(wrapper.getBoundingClientRect()) : void 0;
|
|
126
134
|
await nextTick();
|
|
127
135
|
}
|
|
128
136
|
function checkPosition() {
|
|
@@ -252,13 +260,13 @@ export function useDrawerDrag(args) {
|
|
|
252
260
|
break;
|
|
253
261
|
}
|
|
254
262
|
}
|
|
255
|
-
function
|
|
256
|
-
|
|
257
|
-
shouldClose.value = false;
|
|
258
|
-
interpolateTo.value = void 0;
|
|
263
|
+
function resetListeners() {
|
|
264
|
+
cancelTouchmove?.();
|
|
259
265
|
cancelTouchend?.();
|
|
266
|
+
cancelTouchcancel?.();
|
|
260
267
|
cancelPointerup?.();
|
|
261
268
|
cancelPointermove?.();
|
|
269
|
+
cancelPointercancel?.();
|
|
262
270
|
}
|
|
263
271
|
function resetScrollLock() {
|
|
264
272
|
if (scrollLock?.value) {
|
|
@@ -266,7 +274,12 @@ export function useDrawerDrag(args) {
|
|
|
266
274
|
}
|
|
267
275
|
scrollLock = void 0;
|
|
268
276
|
}
|
|
269
|
-
function
|
|
277
|
+
function resetDragState() {
|
|
278
|
+
dragging.value = false;
|
|
279
|
+
shouldClose.value = false;
|
|
280
|
+
interpolateTo.value = void 0;
|
|
281
|
+
}
|
|
282
|
+
function resetCalcState() {
|
|
270
283
|
draggedX.value = 0;
|
|
271
284
|
draggedY.value = 0;
|
|
272
285
|
lastDraggedX.value = 0;
|
|
@@ -276,15 +289,15 @@ export function useDrawerDrag(args) {
|
|
|
276
289
|
elRect.value = void 0;
|
|
277
290
|
wrapperRect.value = void 0;
|
|
278
291
|
}
|
|
279
|
-
function
|
|
292
|
+
function resetSnapState() {
|
|
280
293
|
snappedX.value = 0;
|
|
281
294
|
snappedY.value = 0;
|
|
282
295
|
activeSnapPoint.value = void 0;
|
|
283
296
|
}
|
|
284
297
|
function afterLeaveCallback(payload) {
|
|
285
298
|
if (payload === toValue(id)) {
|
|
286
|
-
|
|
287
|
-
|
|
299
|
+
resetCalcState();
|
|
300
|
+
resetSnapState();
|
|
288
301
|
}
|
|
289
302
|
}
|
|
290
303
|
function snapToCallback(payload) {
|
|
@@ -309,6 +322,9 @@ export function useDrawerDrag(args) {
|
|
|
309
322
|
function destroy() {
|
|
310
323
|
emitter.off("snapTo", snapToCallback);
|
|
311
324
|
emitter.off("afterLeave", afterLeaveCallback);
|
|
325
|
+
resizeObserverEl?.stop();
|
|
326
|
+
resetDragState();
|
|
327
|
+
resetListeners();
|
|
312
328
|
}
|
|
313
329
|
function onCancel() {
|
|
314
330
|
switch (position) {
|
|
@@ -325,9 +341,41 @@ export function useDrawerDrag(args) {
|
|
|
325
341
|
});
|
|
326
342
|
break;
|
|
327
343
|
}
|
|
328
|
-
|
|
344
|
+
resetDragState();
|
|
345
|
+
resetListeners();
|
|
329
346
|
resetScrollLock();
|
|
330
347
|
}
|
|
348
|
+
function onPointermove(e) {
|
|
349
|
+
if (e.isTrusted && wheeling.value) {
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
if (e.isTrusted && !e.isPrimary) {
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
e.stopImmediatePropagation();
|
|
356
|
+
e.stopPropagation();
|
|
357
|
+
shouldClose.value = false;
|
|
358
|
+
checkDirection({ x: e.screenX, y: e.screenY });
|
|
359
|
+
if (!scrollLock) {
|
|
360
|
+
const scrollLockTarget = lockScroll(e.target);
|
|
361
|
+
if (scrollLockTarget) {
|
|
362
|
+
scrollLock = useScrollLock(scrollLockTarget);
|
|
363
|
+
scrollLock.value = true;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
const dragTarget = pointerdownTarget ?? e.target;
|
|
367
|
+
if (!canDrag(dragTarget)) {
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
setDragged({ x: e.screenX, y: e.screenY });
|
|
371
|
+
checkMomentum();
|
|
372
|
+
checkPosition();
|
|
373
|
+
emitter.emit("drag", {
|
|
374
|
+
id: toValue(id),
|
|
375
|
+
x: draggedX.value,
|
|
376
|
+
y: draggedY.value
|
|
377
|
+
});
|
|
378
|
+
}
|
|
331
379
|
function onPointerup(e) {
|
|
332
380
|
if (shouldClose.value) {
|
|
333
381
|
close();
|
|
@@ -369,35 +417,40 @@ export function useDrawerDrag(args) {
|
|
|
369
417
|
x: draggedX.value,
|
|
370
418
|
y: draggedY.value
|
|
371
419
|
});
|
|
372
|
-
|
|
420
|
+
resetDragState();
|
|
421
|
+
resetListeners();
|
|
373
422
|
resetScrollLock();
|
|
374
423
|
if (hasDragged.value) {
|
|
375
424
|
e.preventDefault();
|
|
376
425
|
}
|
|
377
426
|
guardedReleasePointerCapture({ event: e, element: pointerdownTarget });
|
|
378
427
|
}
|
|
379
|
-
function
|
|
380
|
-
if (e.isTrusted && wheeling.value) {
|
|
381
|
-
return;
|
|
382
|
-
}
|
|
383
|
-
if (e.isTrusted && !e.isPrimary) {
|
|
384
|
-
return;
|
|
385
|
-
}
|
|
428
|
+
function onTouchmove(e) {
|
|
386
429
|
e.stopImmediatePropagation();
|
|
387
430
|
e.stopPropagation();
|
|
388
431
|
shouldClose.value = false;
|
|
389
|
-
|
|
432
|
+
const firstTouch = e.touches[0];
|
|
433
|
+
if (!firstTouch) {
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
checkDirection({ x: firstTouch.screenX, y: firstTouch.screenY });
|
|
437
|
+
shouldClose.value = false;
|
|
438
|
+
checkDirection({ x: firstTouch.screenX, y: firstTouch.screenY });
|
|
390
439
|
if (!scrollLock) {
|
|
391
|
-
const scrollLockTarget = lockScroll(
|
|
440
|
+
const scrollLockTarget = lockScroll(firstTouch.target);
|
|
392
441
|
if (scrollLockTarget) {
|
|
393
442
|
scrollLock = useScrollLock(scrollLockTarget);
|
|
394
443
|
scrollLock.value = true;
|
|
395
444
|
}
|
|
396
445
|
}
|
|
397
|
-
|
|
446
|
+
const dragTarget = pointerdownTarget ?? e.target;
|
|
447
|
+
if (!canDrag(dragTarget)) {
|
|
398
448
|
return;
|
|
399
449
|
}
|
|
400
|
-
|
|
450
|
+
if (hasDragged.value) {
|
|
451
|
+
e.preventDefault();
|
|
452
|
+
}
|
|
453
|
+
setDragged({ x: firstTouch.screenX, y: firstTouch.screenY });
|
|
401
454
|
checkMomentum();
|
|
402
455
|
checkPosition();
|
|
403
456
|
emitter.emit("drag", {
|
|
@@ -406,6 +459,54 @@ export function useDrawerDrag(args) {
|
|
|
406
459
|
y: draggedY.value
|
|
407
460
|
});
|
|
408
461
|
}
|
|
462
|
+
function onTouchend(e) {
|
|
463
|
+
if (shouldClose.value) {
|
|
464
|
+
close();
|
|
465
|
+
} else if (interpolateTo.value || interpolateTo.value === 0) {
|
|
466
|
+
if (scrollLock && scrollLock.value || canInterpolate(e.target)) {
|
|
467
|
+
interpolateDragged({
|
|
468
|
+
to: interpolateTo.value
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
activeSnapPoint.value = snapPointsMap.value[interpolateTo.value];
|
|
472
|
+
switch (position) {
|
|
473
|
+
case "bottom":
|
|
474
|
+
case "top":
|
|
475
|
+
snappedY.value = interpolateTo.value;
|
|
476
|
+
break;
|
|
477
|
+
case "right":
|
|
478
|
+
case "left":
|
|
479
|
+
snappedX.value = interpolateTo.value;
|
|
480
|
+
break;
|
|
481
|
+
}
|
|
482
|
+
} else {
|
|
483
|
+
switch (position) {
|
|
484
|
+
case "bottom":
|
|
485
|
+
case "top":
|
|
486
|
+
interpolateDragged({
|
|
487
|
+
to: snappedY.value
|
|
488
|
+
});
|
|
489
|
+
break;
|
|
490
|
+
case "right":
|
|
491
|
+
case "left":
|
|
492
|
+
interpolateDragged({
|
|
493
|
+
to: snappedX.value
|
|
494
|
+
});
|
|
495
|
+
break;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
emitter.emit("afterDrag", {
|
|
499
|
+
id: toValue(id),
|
|
500
|
+
x: draggedX.value,
|
|
501
|
+
y: draggedY.value
|
|
502
|
+
});
|
|
503
|
+
resetDragState();
|
|
504
|
+
resetListeners();
|
|
505
|
+
resetScrollLock();
|
|
506
|
+
if (hasDragged.value) {
|
|
507
|
+
e.preventDefault();
|
|
508
|
+
}
|
|
509
|
+
}
|
|
409
510
|
function onPointerdown(e) {
|
|
410
511
|
if (dragging.value) {
|
|
411
512
|
return;
|
|
@@ -420,7 +521,7 @@ export function useDrawerDrag(args) {
|
|
|
420
521
|
pointerdownTarget = e.target;
|
|
421
522
|
guardedSetPointerCapture({
|
|
422
523
|
event: e,
|
|
423
|
-
element:
|
|
524
|
+
element: pointerdownTarget
|
|
424
525
|
});
|
|
425
526
|
emitter.emit("beforeDrag", {
|
|
426
527
|
id: toValue(id),
|
|
@@ -430,19 +531,71 @@ export function useDrawerDrag(args) {
|
|
|
430
531
|
}
|
|
431
532
|
lastDraggedX.value = draggedX.value;
|
|
432
533
|
lastDraggedY.value = draggedY.value;
|
|
534
|
+
resetListeners();
|
|
433
535
|
cancelPointerup = useEventListener(document, "pointerup", onPointerup);
|
|
536
|
+
cancelPointercancel = useEventListener(
|
|
537
|
+
document,
|
|
538
|
+
"pointercancel",
|
|
539
|
+
onPointerup
|
|
540
|
+
);
|
|
434
541
|
cancelPointermove = useEventListener(
|
|
435
542
|
document,
|
|
436
543
|
"pointermove",
|
|
437
544
|
onPointermove,
|
|
438
545
|
{ passive: false }
|
|
439
546
|
);
|
|
440
|
-
|
|
547
|
+
cancelTouchmove = isAndroid() ? useEventListener(document, "touchmove", onTouchmove, {
|
|
548
|
+
passive: false
|
|
549
|
+
}) : void 0;
|
|
550
|
+
cancelTouchend = isIOS() || isAndroid() ? useEventListener(document, "touchend", onTouchend) : void 0;
|
|
551
|
+
cancelTouchcancel = isIOS() || isAndroid() ? useEventListener(document, "touchcancel", onTouchend) : void 0;
|
|
441
552
|
originX.value = e.screenX - draggedX.value;
|
|
442
553
|
originY.value = e.screenY - draggedY.value;
|
|
443
554
|
dragStart.value = /* @__PURE__ */ new Date();
|
|
444
555
|
onPointermove(e);
|
|
445
556
|
}
|
|
557
|
+
function onTouchstart(e) {
|
|
558
|
+
if (!isAndroid()) {
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
if (dragging.value) {
|
|
562
|
+
return;
|
|
563
|
+
} else {
|
|
564
|
+
const isSelect = ["SELECT", "OPTION"].includes(
|
|
565
|
+
e.target.tagName
|
|
566
|
+
);
|
|
567
|
+
if (isSelect) {
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
570
|
+
e.stopImmediatePropagation();
|
|
571
|
+
e.stopPropagation();
|
|
572
|
+
dragging.value = true;
|
|
573
|
+
pointerdownTarget = e.target;
|
|
574
|
+
emitter.emit("beforeDrag", {
|
|
575
|
+
id: toValue(id),
|
|
576
|
+
x: draggedX.value,
|
|
577
|
+
y: draggedY.value
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
cancelTouchmove?.();
|
|
581
|
+
cancelTouchmove = useEventListener(document, "touchmove", onTouchmove, {
|
|
582
|
+
passive: false
|
|
583
|
+
});
|
|
584
|
+
cancelTouchend?.();
|
|
585
|
+
cancelTouchend = useEventListener(document, "touchend", onTouchend, {
|
|
586
|
+
passive: false
|
|
587
|
+
});
|
|
588
|
+
cancelTouchcancel?.();
|
|
589
|
+
cancelTouchcancel = useEventListener(document, "touchcancel", onTouchend);
|
|
590
|
+
const firstTouch = e.touches[0];
|
|
591
|
+
if (!firstTouch) {
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
originX.value = firstTouch.screenX - draggedX.value;
|
|
595
|
+
originY.value = firstTouch.screenY - draggedY.value;
|
|
596
|
+
dragStart.value = /* @__PURE__ */ new Date();
|
|
597
|
+
onTouchmove(e);
|
|
598
|
+
}
|
|
446
599
|
function onClick(e) {
|
|
447
600
|
if (hasDragged.value) {
|
|
448
601
|
e.preventDefault();
|
|
@@ -473,7 +626,7 @@ export function useDrawerDrag(args) {
|
|
|
473
626
|
}
|
|
474
627
|
}
|
|
475
628
|
);
|
|
476
|
-
useResizeObserver(elRef, async () => {
|
|
629
|
+
resizeObserverEl = useResizeObserver(elRef, async () => {
|
|
477
630
|
useThrottleFn(async () => {
|
|
478
631
|
await getSizes();
|
|
479
632
|
if (activeSnapPoint.value) {
|
|
@@ -482,11 +635,13 @@ export function useDrawerDrag(args) {
|
|
|
482
635
|
}
|
|
483
636
|
}, 100)();
|
|
484
637
|
});
|
|
485
|
-
|
|
638
|
+
onScopeDispose(() => {
|
|
486
639
|
destroy();
|
|
487
640
|
});
|
|
488
641
|
return {
|
|
489
642
|
onPointerdown,
|
|
643
|
+
onTouchstart,
|
|
644
|
+
onTouchmove,
|
|
490
645
|
onClick,
|
|
491
646
|
style,
|
|
492
647
|
hasDragged
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type MaybeRef } from 'vue';
|
|
2
2
|
import type { DrawerState } from '../../types/index.js';
|
|
3
3
|
export declare function useDrawerState(id: MaybeRef<string>): {
|
|
4
4
|
initializeState: () => DrawerState;
|
|
5
|
-
|
|
6
|
-
drawerStateStore: Ref<DrawerState[], DrawerState[]>;
|
|
5
|
+
drawerStateStore: import("vue").Ref<DrawerState[], DrawerState[]>;
|
|
7
6
|
};
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { reactive, toValue, onScopeDispose } from "vue";
|
|
2
|
+
import { createStateStore } from "@maas/vue-equipment/utils";
|
|
3
|
+
const getDrawerStateStore = createStateStore(
|
|
4
|
+
"MagicDrawer",
|
|
5
|
+
() => []
|
|
6
|
+
);
|
|
3
7
|
export function useDrawerState(id) {
|
|
8
|
+
const drawerStateStore = getDrawerStateStore();
|
|
9
|
+
let scopeCounted = false;
|
|
4
10
|
function createState(id2) {
|
|
5
11
|
const state = {
|
|
6
12
|
id: id2,
|
|
13
|
+
refCount: 0,
|
|
7
14
|
active: false,
|
|
8
15
|
dragStart: void 0,
|
|
9
16
|
dragging: false,
|
|
@@ -34,21 +41,39 @@ export function useDrawerState(id) {
|
|
|
34
41
|
drawerStateStore.value = [...drawerStateStore.value, state];
|
|
35
42
|
return state;
|
|
36
43
|
}
|
|
44
|
+
function deleteState() {
|
|
45
|
+
const currentId = toValue(id);
|
|
46
|
+
drawerStateStore.value = drawerStateStore.value.filter(
|
|
47
|
+
(x) => x.id !== currentId
|
|
48
|
+
);
|
|
49
|
+
}
|
|
37
50
|
function initializeState() {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
});
|
|
51
|
+
const currentId = toValue(id);
|
|
52
|
+
let state = drawerStateStore.value.find((entry) => entry.id === currentId);
|
|
41
53
|
if (!state) {
|
|
42
|
-
state = addState(
|
|
54
|
+
state = addState(currentId);
|
|
55
|
+
}
|
|
56
|
+
if (!scopeCounted) {
|
|
57
|
+
state.refCount++;
|
|
58
|
+
scopeCounted = true;
|
|
43
59
|
}
|
|
44
60
|
return state;
|
|
45
61
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
62
|
+
onScopeDispose(() => {
|
|
63
|
+
if (!scopeCounted) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const currentId = toValue(id);
|
|
67
|
+
const state = drawerStateStore.value.find((entry) => entry.id === currentId);
|
|
68
|
+
if (state) {
|
|
69
|
+
state.refCount--;
|
|
70
|
+
if (state.refCount <= 0) {
|
|
71
|
+
deleteState();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
49
75
|
return {
|
|
50
76
|
initializeState,
|
|
51
|
-
deleteState,
|
|
52
77
|
drawerStateStore
|
|
53
78
|
};
|
|
54
79
|
}
|
|
@@ -5,6 +5,7 @@ export function useMagicDrawer(id) {
|
|
|
5
5
|
const { initializeState } = useDrawerState(toValue(id));
|
|
6
6
|
const state = initializeState();
|
|
7
7
|
const { progress, active } = toRefs(state);
|
|
8
|
+
const emitter = useMagicEmitter();
|
|
8
9
|
const isActive = computed(() => active.value);
|
|
9
10
|
function open() {
|
|
10
11
|
active.value = true;
|
|
@@ -13,7 +14,7 @@ export function useMagicDrawer(id) {
|
|
|
13
14
|
active.value = false;
|
|
14
15
|
}
|
|
15
16
|
function snapTo(snapPoint, duration) {
|
|
16
|
-
|
|
17
|
+
emitter.emit("snapTo", {
|
|
17
18
|
id: toValue(id),
|
|
18
19
|
snapPoint,
|
|
19
20
|
duration
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import mitt from "mitt";
|
|
2
|
-
|
|
1
|
+
import mitt, {} from "mitt";
|
|
2
|
+
import { createStateStore } from "@maas/vue-equipment/utils";
|
|
3
|
+
const getEmitter = createStateStore(
|
|
4
|
+
"MagicEmitter",
|
|
5
|
+
() => mitt()
|
|
6
|
+
);
|
|
3
7
|
export function useMagicEmitter() {
|
|
8
|
+
const emitter = getEmitter();
|
|
4
9
|
return {
|
|
5
|
-
on: emitter.on,
|
|
6
|
-
off: emitter.off,
|
|
7
|
-
emit: emitter.emit
|
|
10
|
+
on: emitter.value.on,
|
|
11
|
+
off: emitter.value.off,
|
|
12
|
+
emit: emitter.value.emit
|
|
8
13
|
};
|
|
9
14
|
}
|
|
@@ -17,14 +17,14 @@
|
|
|
17
17
|
</template>
|
|
18
18
|
|
|
19
19
|
<script setup>
|
|
20
|
-
import { useTemplateRef, onMounted
|
|
20
|
+
import { useTemplateRef, onMounted } from "vue";
|
|
21
21
|
import { useMarqueeApi } from "../composables/private/useMarqueeApi";
|
|
22
22
|
import { useMarqueeState } from "../composables/private/useMarqueeState";
|
|
23
23
|
const { id, options } = defineProps({
|
|
24
24
|
id: { type: null, required: true },
|
|
25
25
|
options: { type: Object, required: false }
|
|
26
26
|
});
|
|
27
|
-
const {
|
|
27
|
+
const { initializeState } = useMarqueeState(id);
|
|
28
28
|
initializeState(options);
|
|
29
29
|
const parentRef = useTemplateRef("parent");
|
|
30
30
|
const childRef = useTemplateRef("child");
|
|
@@ -36,9 +36,6 @@ const { duplicates, initialize } = useMarqueeApi({
|
|
|
36
36
|
onMounted(() => {
|
|
37
37
|
initialize();
|
|
38
38
|
});
|
|
39
|
-
onBeforeUnmount(() => {
|
|
40
|
-
deleteState();
|
|
41
|
-
});
|
|
42
39
|
</script>
|
|
43
40
|
|
|
44
41
|
<style>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type MaybeRef } from 'vue';
|
|
2
2
|
import type { MarqueeState, MagicMarqueeOptions } from '../../types/index.js';
|
|
3
3
|
export declare function useMarqueeState(instanceId: MaybeRef<string>): {
|
|
4
4
|
initializeState: (options?: MagicMarqueeOptions) => MarqueeState;
|
|
5
|
-
|
|
6
|
-
marqueeStateStore: Ref<MarqueeState[], MarqueeState[]>;
|
|
5
|
+
marqueeStateStore: import("vue").Ref<MarqueeState[], MarqueeState[]>;
|
|
7
6
|
};
|