@maas/vue-equipment 0.21.2 → 0.21.4
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/nuxt/module.json +1 -1
- package/dist/plugins/MagicPlayer/src/components/MagicPlayer.vue +7 -2
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerControlsApi.mjs +2 -2
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerRuntime.d.ts +2 -0
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerRuntime.mjs +8 -6
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerVideoApi.d.ts +4 -4
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerVideoApi.mjs +1 -1
- package/dist/plugins/MagicPlayer/src/composables/usePlayerApi.d.ts +3 -0
- package/dist/plugins/MagicScroll/src/components/MagicScrollMotion.vue +19 -11
- package/dist/plugins/MagicScroll/src/components/MagicScrollMotion.vue.d.ts +3 -8
- package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue +2 -4
- package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue.d.ts +0 -2
- package/package.json +1 -1
package/dist/nuxt/module.json
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
</template>
|
|
20
20
|
|
|
21
21
|
<script setup lang="ts">
|
|
22
|
-
import { ref, computed, onMounted } from 'vue'
|
|
22
|
+
import { ref, computed, onMounted, onBeforeUnmount } from 'vue'
|
|
23
23
|
import { useIntersectionObserver } from '@vueuse/core'
|
|
24
24
|
import { usePlayerVideoApi } from '../composables/private/usePlayerVideoApi'
|
|
25
25
|
import { usePlayerMediaApi } from '../composables/private/usePlayerMediaApi'
|
|
@@ -54,7 +54,7 @@ const { playing, muted } = usePlayerMediaApi({
|
|
|
54
54
|
mediaRef: videoRef,
|
|
55
55
|
})
|
|
56
56
|
|
|
57
|
-
usePlayerRuntime({
|
|
57
|
+
const { initialize, destroy } = usePlayerRuntime({
|
|
58
58
|
id: props.id,
|
|
59
59
|
mediaRef: videoRef,
|
|
60
60
|
src: props.src,
|
|
@@ -100,10 +100,15 @@ const computedStyle = computed(() => {
|
|
|
100
100
|
})
|
|
101
101
|
|
|
102
102
|
onMounted(() => {
|
|
103
|
+
initialize()
|
|
103
104
|
if (props.autoplay) {
|
|
104
105
|
muted.value = true
|
|
105
106
|
}
|
|
106
107
|
})
|
|
108
|
+
|
|
109
|
+
onBeforeUnmount(() => {
|
|
110
|
+
destroy()
|
|
111
|
+
})
|
|
107
112
|
</script>
|
|
108
113
|
|
|
109
114
|
<style>
|
|
@@ -15,10 +15,10 @@ export function usePlayerControlsApi(args) {
|
|
|
15
15
|
const popoverRect = ref(void 0);
|
|
16
16
|
const { trackRef, barRef, popoverRef } = args;
|
|
17
17
|
const { buffered, duration, playing, currentTime } = usePlayerMediaApi({
|
|
18
|
-
id:
|
|
18
|
+
id: args.id
|
|
19
19
|
});
|
|
20
20
|
const { play, pause, seek } = usePlayerVideoApi({
|
|
21
|
-
id:
|
|
21
|
+
id: args.id
|
|
22
22
|
});
|
|
23
23
|
const dragging = ref(false);
|
|
24
24
|
const mouseEntered = ref(false);
|
|
@@ -8,5 +8,7 @@ export type UsePlayerRuntimeArgs = {
|
|
|
8
8
|
};
|
|
9
9
|
export declare function usePlayerRuntime(args: UsePlayerRuntimeArgs): {
|
|
10
10
|
loaded: import("vue").Ref<boolean>;
|
|
11
|
+
initialize: () => void;
|
|
12
|
+
destroy: () => void;
|
|
11
13
|
};
|
|
12
14
|
export type UsePlayerRuntimeReturn = ReturnType<typeof usePlayerRuntime>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ref, watch,
|
|
1
|
+
import { ref, watch, toValue } from "vue";
|
|
2
2
|
import { usePlayerStateEmitter } from "./usePlayerStateEmitter.mjs";
|
|
3
3
|
export function usePlayerRuntime(args) {
|
|
4
4
|
let hls;
|
|
@@ -34,16 +34,16 @@ export function usePlayerRuntime(args) {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
|
|
37
|
+
function initialize() {
|
|
38
38
|
if (srcType === "native") {
|
|
39
39
|
useNative();
|
|
40
40
|
} else if (srcType === "hls") {
|
|
41
41
|
useHlsJS();
|
|
42
42
|
}
|
|
43
|
-
}
|
|
44
|
-
|
|
43
|
+
}
|
|
44
|
+
function destroy() {
|
|
45
45
|
hls?.destroy();
|
|
46
|
-
}
|
|
46
|
+
}
|
|
47
47
|
const emitter = usePlayerStateEmitter();
|
|
48
48
|
emitter.on("update", (payload) => {
|
|
49
49
|
if (payload.id !== toValue(args.id))
|
|
@@ -65,6 +65,8 @@ export function usePlayerRuntime(args) {
|
|
|
65
65
|
});
|
|
66
66
|
});
|
|
67
67
|
return {
|
|
68
|
-
loaded
|
|
68
|
+
loaded,
|
|
69
|
+
initialize,
|
|
70
|
+
destroy
|
|
69
71
|
};
|
|
70
72
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { type MaybeRef
|
|
1
|
+
import { type MaybeRef } from 'vue';
|
|
2
2
|
export type UsePlayerVideoApiArgs = {
|
|
3
3
|
id: MaybeRef<string>;
|
|
4
4
|
playerRef?: MaybeRef<HTMLElement | undefined>;
|
|
5
5
|
videoRef?: MaybeRef<HTMLVideoElement | undefined>;
|
|
6
6
|
};
|
|
7
7
|
export declare function usePlayerVideoApi(args: UsePlayerVideoApiArgs): {
|
|
8
|
-
mouseEntered: Ref<boolean>;
|
|
9
|
-
isFullscreen: Ref<boolean>;
|
|
10
|
-
touched: Ref<boolean>;
|
|
8
|
+
mouseEntered: import("vue").Ref<boolean>;
|
|
9
|
+
isFullscreen: import("vue").Ref<boolean>;
|
|
10
|
+
touched: import("vue").Ref<boolean>;
|
|
11
11
|
play: () => void;
|
|
12
12
|
pause: () => void;
|
|
13
13
|
togglePlay: () => void;
|
|
@@ -6,7 +6,7 @@ import { usePlayerMediaApi } from "./usePlayerMediaApi.mjs";
|
|
|
6
6
|
export function usePlayerVideoApi(args) {
|
|
7
7
|
const fullscreenTarget = ref(void 0);
|
|
8
8
|
const { playing, currentTime, muted } = usePlayerMediaApi({
|
|
9
|
-
id:
|
|
9
|
+
id: args.id
|
|
10
10
|
});
|
|
11
11
|
const { playerRef, videoRef } = args;
|
|
12
12
|
const touched = ref(false);
|
|
@@ -59,6 +59,9 @@ export declare function usePlayerApi(args: usePlayerApiArgs): {
|
|
|
59
59
|
};
|
|
60
60
|
playerRuntime: {
|
|
61
61
|
loaded: import("vue").Ref<boolean>;
|
|
62
|
+
initialize: () => void;
|
|
63
|
+
destroy: () => void;
|
|
62
64
|
};
|
|
63
65
|
};
|
|
66
|
+
export type UsePlayerApiApiReturn = ReturnType<typeof usePlayerApi>;
|
|
64
67
|
export {};
|
|
@@ -7,32 +7,40 @@
|
|
|
7
7
|
<script setup lang="ts">
|
|
8
8
|
import { ref, inject, computed, onMounted, watch } from 'vue'
|
|
9
9
|
import { unrefElement } from '@vueuse/core'
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
animate,
|
|
12
|
+
type MotionKeyframesDefinition,
|
|
13
|
+
type AnimationControls,
|
|
14
|
+
type Easing,
|
|
15
|
+
} from 'motion'
|
|
11
16
|
import { ScrollProgressKey } from '../symbols'
|
|
12
17
|
|
|
13
18
|
interface Props {
|
|
14
|
-
keyframes:
|
|
19
|
+
keyframes: MotionKeyframesDefinition
|
|
15
20
|
offset?: number[] | undefined
|
|
16
21
|
easing?: Easing
|
|
22
|
+
progress?: number
|
|
17
23
|
}
|
|
18
24
|
|
|
19
25
|
const props = withDefaults(defineProps<Props>(), {
|
|
20
|
-
keyframes: undefined,
|
|
21
|
-
offset: undefined,
|
|
22
26
|
easing: 'linear',
|
|
23
27
|
})
|
|
24
28
|
|
|
25
|
-
const animation = ref()
|
|
26
|
-
const elRef = ref()
|
|
29
|
+
const animation = ref<AnimationControls | undefined>(undefined)
|
|
30
|
+
const elRef = ref<HTMLElement | undefined>(undefined)
|
|
27
31
|
|
|
28
32
|
const progress = inject(
|
|
29
33
|
ScrollProgressKey,
|
|
30
34
|
computed(() => 0)
|
|
31
35
|
)
|
|
32
36
|
|
|
37
|
+
const mappedProgress = computed(() => {
|
|
38
|
+
return props.progress || progress.value
|
|
39
|
+
})
|
|
40
|
+
|
|
33
41
|
function createAnimation(currentTime: number = 0) {
|
|
34
42
|
if (!props.keyframes) return
|
|
35
|
-
animation.value = animate(unrefElement(elRef)
|
|
43
|
+
animation.value = animate(unrefElement(elRef)!, props.keyframes, {
|
|
36
44
|
duration: 1,
|
|
37
45
|
easing: props.easing || 'linear',
|
|
38
46
|
offset: props.offset,
|
|
@@ -45,16 +53,16 @@ onMounted(() => {
|
|
|
45
53
|
createAnimation()
|
|
46
54
|
})
|
|
47
55
|
|
|
48
|
-
watch(
|
|
49
|
-
if (!value || !animation.value || !props.keyframes) return
|
|
56
|
+
watch(mappedProgress, (value) => {
|
|
57
|
+
if ((!value && value !== 0) || !animation.value || !props.keyframes) return
|
|
50
58
|
animation.value.currentTime = value
|
|
51
59
|
})
|
|
52
60
|
|
|
53
61
|
watch(
|
|
54
62
|
() => props.keyframes,
|
|
55
63
|
() => {
|
|
56
|
-
if (
|
|
57
|
-
createAnimation(
|
|
64
|
+
if (mappedProgress.value) {
|
|
65
|
+
createAnimation(mappedProgress.value)
|
|
58
66
|
} else {
|
|
59
67
|
createAnimation()
|
|
60
68
|
}
|
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
import { type Easing } from 'motion';
|
|
1
|
+
import { type MotionKeyframesDefinition, type Easing } from 'motion';
|
|
2
2
|
interface Props {
|
|
3
|
-
keyframes:
|
|
3
|
+
keyframes: MotionKeyframesDefinition;
|
|
4
4
|
offset?: number[] | undefined;
|
|
5
5
|
easing?: Easing;
|
|
6
|
+
progress?: number;
|
|
6
7
|
}
|
|
7
8
|
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
|
|
8
|
-
keyframes: undefined;
|
|
9
|
-
offset: undefined;
|
|
10
9
|
easing: string;
|
|
11
10
|
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
|
|
12
|
-
keyframes: undefined;
|
|
13
|
-
offset: undefined;
|
|
14
11
|
easing: string;
|
|
15
12
|
}>>>, {
|
|
16
|
-
keyframes: Record<string, any> | null | undefined;
|
|
17
|
-
offset: number[];
|
|
18
13
|
easing: Easing;
|
|
19
14
|
}, {}>, {
|
|
20
15
|
default?(_: {}): any;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div ref="elRef" class="magic-scroll-scene">
|
|
3
|
-
<slot :
|
|
3
|
+
<slot :progress="progress" />
|
|
4
4
|
</div>
|
|
5
5
|
</template>
|
|
6
6
|
|
|
7
7
|
<script setup lang="ts">
|
|
8
8
|
import { ref, provide, inject, onMounted, watch, nextTick, readonly } from 'vue'
|
|
9
|
-
import {
|
|
10
|
-
import { mapValue } from '@maas/vue-equipment/utils'
|
|
9
|
+
import { useIntersectionObserver } from '@vueuse/core'
|
|
11
10
|
import { useScrollApi } from '../composables/useScrollApi'
|
|
12
11
|
import {
|
|
13
12
|
ScrollPositionKey,
|
|
@@ -71,6 +70,5 @@ useIntersectionObserver(
|
|
|
71
70
|
{ rootMargin: '150% 0px 150% 0px', threshold: 0.01 }
|
|
72
71
|
)
|
|
73
72
|
|
|
74
|
-
provide('mapValue', mapValue)
|
|
75
73
|
provide(ScrollProgressKey, readonly(progress))
|
|
76
74
|
</script>
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { mapValue } from '@maas/vue-equipment/utils';
|
|
2
1
|
import type { FromTo } from '../types';
|
|
3
2
|
interface Props {
|
|
4
3
|
from?: FromTo;
|
|
@@ -16,7 +15,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
16
15
|
from: FromTo;
|
|
17
16
|
}, {}>, {
|
|
18
17
|
default?(_: {
|
|
19
|
-
mapValue: typeof mapValue;
|
|
20
18
|
progress: number;
|
|
21
19
|
}): any;
|
|
22
20
|
}>;
|
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.21.
|
|
4
|
+
"version": "0.21.4",
|
|
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",
|