@maas/vue-equipment 1.0.0-beta.13 → 1.0.0-beta.15
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/MagicAccordion/src/components/MagicAccordionContent.vue +65 -82
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionContent.vue.d.ts +2 -2
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionProvider.vue +24 -30
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionTrigger.vue +65 -61
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionTrigger.vue.d.ts +1 -1
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionView.vue +41 -45
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionView.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandContent.vue +137 -150
- package/dist/plugins/MagicCommand/src/components/MagicCommandContent.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandDrawer.vue +45 -52
- package/dist/plugins/MagicCommand/src/components/MagicCommandItem.vue +80 -82
- package/dist/plugins/MagicCommand/src/components/MagicCommandItem.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandModal.vue +40 -47
- package/dist/plugins/MagicCommand/src/components/MagicCommandProvider.vue +68 -74
- package/dist/plugins/MagicCommand/src/components/MagicCommandRenderer.vue +22 -38
- package/dist/plugins/MagicCommand/src/components/MagicCommandTrigger.vue +95 -85
- package/dist/plugins/MagicCommand/src/components/MagicCommandTrigger.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandView.vue +41 -47
- package/dist/plugins/MagicCommand/src/components/MagicCommandView.vue.d.ts +1 -1
- package/dist/plugins/MagicCookie/src/components/MagicCookieItem.vue +41 -39
- package/dist/plugins/MagicCookie/src/components/MagicCookieItem.vue.d.ts +2 -2
- package/dist/plugins/MagicCookie/src/components/MagicCookieProvider.vue +23 -34
- package/dist/plugins/MagicCookie/src/components/MagicCookieView.vue +40 -73
- package/dist/plugins/MagicCookie/src/components/MagicCookieView.vue.d.ts +1 -1
- package/dist/plugins/MagicDraggable/src/components/MagicDraggable.vue +70 -86
- package/dist/plugins/MagicDraggable/src/components/MagicDraggable.vue.d.ts +14 -13
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue +263 -303
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue.d.ts +50 -49
- package/dist/plugins/MagicEmitter/src/composables/useMagicEmitter.d.ts +100 -100
- package/dist/plugins/MagicMarquee/src/components/MagicMarquee.vue +41 -69
- package/dist/plugins/MagicMarquee/src/composables/useMagicMarquee.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuChannel.vue +54 -59
- package/dist/plugins/MagicMenu/src/components/MagicMenuChannel.vue.d.ts +2 -2
- package/dist/plugins/MagicMenu/src/components/MagicMenuContent.vue +188 -208
- package/dist/plugins/MagicMenu/src/components/MagicMenuContent.vue.d.ts +3 -3
- package/dist/plugins/MagicMenu/src/components/MagicMenuFloat.vue +181 -194
- package/dist/plugins/MagicMenu/src/components/MagicMenuItem.vue +91 -100
- package/dist/plugins/MagicMenu/src/components/MagicMenuItem.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuProvider.vue +83 -85
- package/dist/plugins/MagicMenu/src/components/MagicMenuRemote.vue +79 -75
- package/dist/plugins/MagicMenu/src/components/MagicMenuRemote.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuTrigger.vue +106 -105
- package/dist/plugins/MagicMenu/src/components/MagicMenuTrigger.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuView.vue +54 -60
- package/dist/plugins/MagicMenu/src/components/MagicMenuView.vue.d.ts +1 -1
- package/dist/plugins/MagicModal/src/components/MagicModal.vue +137 -163
- package/dist/plugins/MagicModal/src/components/MagicModal.vue.d.ts +9 -8
- package/dist/plugins/MagicNoise/src/components/MagicNoise.vue +53 -78
- package/dist/plugins/MagicPie/src/components/MagicPie.vue +147 -175
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudio.vue +49 -65
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudioControls.vue +87 -129
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerDisplayTime.vue +33 -41
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerMuxPopover.vue +99 -109
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerOverlay.vue +47 -75
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerPoster.vue +16 -31
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerProvider.vue +43 -44
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerTimeline.vue +52 -109
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideo.vue +65 -72
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideoControls.vue +154 -225
- package/dist/plugins/MagicPlayer/src/composables/useMagicPlayer.d.ts +1 -1
- package/dist/plugins/MagicScroll/src/components/MagicScrollCollision.vue +49 -59
- package/dist/plugins/MagicScroll/src/components/MagicScrollMotion.vue +63 -70
- package/dist/plugins/MagicScroll/src/components/MagicScrollProvider.vue +29 -33
- package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue +59 -69
- package/dist/plugins/MagicToast/src/components/MagicToastProvider.vue +81 -94
- package/dist/plugins/MagicToast/src/components/MagicToastView.vue +52 -70
- package/dist/plugins/MagicToast/src/components/MagicToastView.vue.d.ts +2 -2
- package/package.json +1 -1
- package/dist/plugins/MagicAccordion/demo/data/footer.json +0 -117
- package/dist/plugins/MagicCommand/demo/data/about.json +0 -3
- package/dist/plugins/MagicCommand/demo/data/search.json +0 -594
|
@@ -1,20 +1,81 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
ref="el"
|
|
4
|
+
class="magic-player-video-controls"
|
|
5
|
+
:data-fullscreen="isFullscreen"
|
|
6
|
+
:data-touched="touched"
|
|
7
|
+
:data-playing="playing"
|
|
8
|
+
:data-paused="!playing"
|
|
9
|
+
:data-waiting="waiting"
|
|
10
|
+
:data-muted="muted"
|
|
11
|
+
:data-idle="idle"
|
|
12
|
+
:data-hover="controlsMouseEntered"
|
|
13
|
+
:data-standalone="standalone"
|
|
14
|
+
@mouseenter="onMouseenter"
|
|
15
|
+
@mouseleave="onMouseleave"
|
|
16
|
+
>
|
|
17
|
+
<transition :name="mappedTransition">
|
|
18
|
+
<div v-show="!hidden" class="magic-player-video-controls__bar">
|
|
19
|
+
<div
|
|
20
|
+
v-if="$slots.popover"
|
|
21
|
+
v-show="!!seekedTime && touched"
|
|
22
|
+
ref="popover"
|
|
23
|
+
class="magic-player-video-controls__popover"
|
|
24
|
+
:style="{ marginLeft: `${popoverOffsetX}%` }"
|
|
25
|
+
>
|
|
26
|
+
<slot name="popover" />
|
|
27
|
+
</div>
|
|
28
|
+
<div ref="bar" class="magic-player-video-controls__bar--inner">
|
|
29
|
+
<div class="magic-player-video-controls__item -shrink-0">
|
|
30
|
+
<button v-if="!playing" @click="play">
|
|
31
|
+
<slot name="playIcon">
|
|
32
|
+
<icon-play />
|
|
33
|
+
</slot>
|
|
34
|
+
</button>
|
|
35
|
+
<button v-else @click="pause">
|
|
36
|
+
<slot name="pauseIcon">
|
|
37
|
+
<icon-pause />
|
|
38
|
+
</slot>
|
|
39
|
+
</button>
|
|
40
|
+
</div>
|
|
41
|
+
<div class="magic-player-video-controls__item -grow">
|
|
42
|
+
<slot name="timelineBefore" />
|
|
43
|
+
<div ref="track" class="magic-player-video-controls__timeline">
|
|
44
|
+
<magic-player-timeline />
|
|
45
|
+
</div>
|
|
46
|
+
<slot name="timelineAfter" />
|
|
47
|
+
</div>
|
|
48
|
+
<div class="magic-player-video-controls__item -shrink-0">
|
|
49
|
+
<button v-if="muted" @click="unmute">
|
|
50
|
+
<slot name="volumeOffIcon">
|
|
51
|
+
<icon-volume-off />
|
|
52
|
+
</slot>
|
|
53
|
+
</button>
|
|
54
|
+
<button v-else @click="mute">
|
|
55
|
+
<slot name="volumeOnIcon">
|
|
56
|
+
<icon-volume-on />
|
|
57
|
+
</slot>
|
|
58
|
+
</button>
|
|
59
|
+
</div>
|
|
60
|
+
<div class="magic-player-video-controls__item -shrink-0">
|
|
61
|
+
<button v-if="isFullscreen" @click="exitFullscreen">
|
|
62
|
+
<slot name="fullscreenExitIcon">
|
|
63
|
+
<icon-fullscreen-exit />
|
|
64
|
+
</slot>
|
|
65
|
+
</button>
|
|
66
|
+
<button v-else @click="enterFullscreen">
|
|
67
|
+
<slot name="fullscreenEnterIcon">
|
|
68
|
+
<icon-fullscreen-enter />
|
|
69
|
+
</slot>
|
|
70
|
+
</button>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</transition>
|
|
75
|
+
</div>
|
|
76
|
+
</template>
|
|
77
|
+
|
|
78
|
+
<script setup>
|
|
18
79
|
import {
|
|
19
80
|
toRefs,
|
|
20
81
|
computed,
|
|
@@ -24,12 +85,6 @@ import {
|
|
|
24
85
|
onBeforeUnmount
|
|
25
86
|
} from "vue";
|
|
26
87
|
import { useElementVisibility, useIdle } from "@vueuse/core";
|
|
27
|
-
import IconPlay from "./icons/Play.vue";
|
|
28
|
-
import IconPause from "./icons/Pause.vue";
|
|
29
|
-
import IconVolumeOn from "./icons/VolumeOn.vue";
|
|
30
|
-
import IconVolumeOff from "./icons/VolumeOff.vue";
|
|
31
|
-
import IconFullscreenEnter from "./icons/FullscreenEnter.vue";
|
|
32
|
-
import IconFullscreenExit from "./icons/FullscreenExit.vue";
|
|
33
88
|
import { usePlayerState } from "../composables/private/usePlayerState";
|
|
34
89
|
import { usePlayerVideoApi } from "../composables/private/usePlayerVideoApi";
|
|
35
90
|
import { usePlayerControlsApi } from "../composables/private/usePlayerControlsApi";
|
|
@@ -42,209 +97,83 @@ import {
|
|
|
42
97
|
} from "../symbols";
|
|
43
98
|
import "@maas/vue-equipment/utils/css/animations/fade-up-in.css";
|
|
44
99
|
import "@maas/vue-equipment/utils/css/animations/fade-up-out.css";
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
100
|
+
const {
|
|
101
|
+
id,
|
|
102
|
+
standalone = false,
|
|
103
|
+
transition
|
|
104
|
+
} = defineProps({
|
|
105
|
+
id: {
|
|
106
|
+
type: String,
|
|
107
|
+
required: false
|
|
51
108
|
},
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
const injectedOptions = inject(MagicPlayerOptionsKey, void 0);
|
|
61
|
-
const mappedTransition = computed(
|
|
62
|
-
() => __props.transition ?? injectedOptions?.transition?.videoControls
|
|
63
|
-
);
|
|
64
|
-
const barRef = useTemplateRef("bar");
|
|
65
|
-
const trackRef = useTemplateRef("track");
|
|
66
|
-
const popoverRef = useTemplateRef("popover");
|
|
67
|
-
const { initializeState } = usePlayerState(mappedInstanceId.value);
|
|
68
|
-
const state = initializeState();
|
|
69
|
-
const {
|
|
70
|
-
playing,
|
|
71
|
-
waiting,
|
|
72
|
-
muted,
|
|
73
|
-
touched,
|
|
74
|
-
mouseEntered,
|
|
75
|
-
controlsMouseEntered,
|
|
76
|
-
isFullscreen,
|
|
77
|
-
popoverOffsetX,
|
|
78
|
-
seekedTime
|
|
79
|
-
} = toRefs(state);
|
|
80
|
-
const { play, pause, mute, unmute, enterFullscreen, exitFullscreen } = usePlayerVideoApi({ id: mappedInstanceId.value });
|
|
81
|
-
const { initialize, destroy, onMouseenter, onMouseleave } = usePlayerControlsApi({
|
|
82
|
-
id: mappedInstanceId.value,
|
|
83
|
-
barRef,
|
|
84
|
-
trackRef,
|
|
85
|
-
popoverRef
|
|
86
|
-
});
|
|
87
|
-
const elRef = useTemplateRef("el");
|
|
88
|
-
const isVisible = useElementVisibility(elRef);
|
|
89
|
-
const { idle } = useIdle(3e3);
|
|
90
|
-
const hidden = computed(() => {
|
|
91
|
-
switch (true) {
|
|
92
|
-
case __props.standalone:
|
|
93
|
-
return false;
|
|
94
|
-
case (playing.value && idle.value):
|
|
95
|
-
return true;
|
|
96
|
-
case (playing.value && !controlsMouseEntered.value && !mouseEntered.value):
|
|
97
|
-
return true;
|
|
98
|
-
case !isVisible.value:
|
|
99
|
-
return true;
|
|
100
|
-
case !touched.value:
|
|
101
|
-
return true;
|
|
102
|
-
default:
|
|
103
|
-
return false;
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
initialize();
|
|
107
|
-
onBeforeUnmount(() => {
|
|
108
|
-
destroy();
|
|
109
|
-
});
|
|
110
|
-
provide(MagicPlayerInstanceId, mappedInstanceId.value);
|
|
111
|
-
provide(MagicPlayerTrackRef, trackRef);
|
|
112
|
-
provide(MagicPlayerPopoverRef, popoverRef);
|
|
113
|
-
provide(MagicPlayerBarRef, barRef);
|
|
114
|
-
return (_ctx, _cache) => {
|
|
115
|
-
const _component_magic_player_timeline = _resolveComponent("magic-player-timeline");
|
|
116
|
-
return _openBlock(), _createElementBlock("div", {
|
|
117
|
-
ref: "el",
|
|
118
|
-
class: "magic-player-video-controls",
|
|
119
|
-
"data-fullscreen": _unref(isFullscreen),
|
|
120
|
-
"data-touched": _unref(touched),
|
|
121
|
-
"data-playing": _unref(playing),
|
|
122
|
-
"data-paused": !_unref(playing),
|
|
123
|
-
"data-waiting": _unref(waiting),
|
|
124
|
-
"data-muted": _unref(muted),
|
|
125
|
-
"data-idle": _unref(idle),
|
|
126
|
-
"data-hover": _unref(controlsMouseEntered),
|
|
127
|
-
"data-standalone": _ctx.standalone,
|
|
128
|
-
onMouseenter: _cache[6] || (_cache[6] = //@ts-ignore
|
|
129
|
-
(...args) => _unref(onMouseenter) && _unref(onMouseenter)(...args)),
|
|
130
|
-
onMouseleave: _cache[7] || (_cache[7] = //@ts-ignore
|
|
131
|
-
(...args) => _unref(onMouseleave) && _unref(onMouseleave)(...args))
|
|
132
|
-
}, [
|
|
133
|
-
_createVNode(_Transition, {
|
|
134
|
-
name: mappedTransition.value,
|
|
135
|
-
persisted: ""
|
|
136
|
-
}, {
|
|
137
|
-
default: _withCtx(() => [
|
|
138
|
-
_withDirectives(_createElementVNode(
|
|
139
|
-
"div",
|
|
140
|
-
_hoisted_2,
|
|
141
|
-
[
|
|
142
|
-
_ctx.$slots.popover ? _withDirectives((_openBlock(), _createElementBlock(
|
|
143
|
-
"div",
|
|
144
|
-
{
|
|
145
|
-
key: 0,
|
|
146
|
-
ref: "popover",
|
|
147
|
-
class: "magic-player-video-controls__popover",
|
|
148
|
-
style: _normalizeStyle({ marginLeft: `${_unref(popoverOffsetX)}%` })
|
|
149
|
-
},
|
|
150
|
-
[
|
|
151
|
-
_renderSlot(_ctx.$slots, "popover")
|
|
152
|
-
],
|
|
153
|
-
4
|
|
154
|
-
/* STYLE */
|
|
155
|
-
)), [
|
|
156
|
-
[_vShow, !!_unref(seekedTime) && _unref(touched)]
|
|
157
|
-
]) : _createCommentVNode("v-if", true),
|
|
158
|
-
_createElementVNode(
|
|
159
|
-
"div",
|
|
160
|
-
_hoisted_3,
|
|
161
|
-
[
|
|
162
|
-
_createElementVNode("div", _hoisted_4, [
|
|
163
|
-
!_unref(playing) ? (_openBlock(), _createElementBlock("button", {
|
|
164
|
-
key: 0,
|
|
165
|
-
onClick: _cache[0] || (_cache[0] = //@ts-ignore
|
|
166
|
-
(...args) => _unref(play) && _unref(play)(...args))
|
|
167
|
-
}, [
|
|
168
|
-
_renderSlot(_ctx.$slots, "playIcon", {}, () => [
|
|
169
|
-
_createVNode(IconPlay)
|
|
170
|
-
])
|
|
171
|
-
])) : (_openBlock(), _createElementBlock("button", {
|
|
172
|
-
key: 1,
|
|
173
|
-
onClick: _cache[1] || (_cache[1] = //@ts-ignore
|
|
174
|
-
(...args) => _unref(pause) && _unref(pause)(...args))
|
|
175
|
-
}, [
|
|
176
|
-
_renderSlot(_ctx.$slots, "pauseIcon", {}, () => [
|
|
177
|
-
_createVNode(IconPause)
|
|
178
|
-
])
|
|
179
|
-
]))
|
|
180
|
-
]),
|
|
181
|
-
_createElementVNode("div", _hoisted_5, [
|
|
182
|
-
_renderSlot(_ctx.$slots, "timelineBefore"),
|
|
183
|
-
_createElementVNode(
|
|
184
|
-
"div",
|
|
185
|
-
_hoisted_6,
|
|
186
|
-
[
|
|
187
|
-
_createVNode(_component_magic_player_timeline)
|
|
188
|
-
],
|
|
189
|
-
512
|
|
190
|
-
/* NEED_PATCH */
|
|
191
|
-
),
|
|
192
|
-
_renderSlot(_ctx.$slots, "timelineAfter")
|
|
193
|
-
]),
|
|
194
|
-
_createElementVNode("div", _hoisted_7, [
|
|
195
|
-
_unref(muted) ? (_openBlock(), _createElementBlock("button", {
|
|
196
|
-
key: 0,
|
|
197
|
-
onClick: _cache[2] || (_cache[2] = //@ts-ignore
|
|
198
|
-
(...args) => _unref(unmute) && _unref(unmute)(...args))
|
|
199
|
-
}, [
|
|
200
|
-
_renderSlot(_ctx.$slots, "volumeOffIcon", {}, () => [
|
|
201
|
-
_createVNode(IconVolumeOff)
|
|
202
|
-
])
|
|
203
|
-
])) : (_openBlock(), _createElementBlock("button", {
|
|
204
|
-
key: 1,
|
|
205
|
-
onClick: _cache[3] || (_cache[3] = //@ts-ignore
|
|
206
|
-
(...args) => _unref(mute) && _unref(mute)(...args))
|
|
207
|
-
}, [
|
|
208
|
-
_renderSlot(_ctx.$slots, "volumeOnIcon", {}, () => [
|
|
209
|
-
_createVNode(IconVolumeOn)
|
|
210
|
-
])
|
|
211
|
-
]))
|
|
212
|
-
]),
|
|
213
|
-
_createElementVNode("div", _hoisted_8, [
|
|
214
|
-
_unref(isFullscreen) ? (_openBlock(), _createElementBlock("button", {
|
|
215
|
-
key: 0,
|
|
216
|
-
onClick: _cache[4] || (_cache[4] = //@ts-ignore
|
|
217
|
-
(...args) => _unref(exitFullscreen) && _unref(exitFullscreen)(...args))
|
|
218
|
-
}, [
|
|
219
|
-
_renderSlot(_ctx.$slots, "fullscreenExitIcon", {}, () => [
|
|
220
|
-
_createVNode(IconFullscreenExit)
|
|
221
|
-
])
|
|
222
|
-
])) : (_openBlock(), _createElementBlock("button", {
|
|
223
|
-
key: 1,
|
|
224
|
-
onClick: _cache[5] || (_cache[5] = //@ts-ignore
|
|
225
|
-
(...args) => _unref(enterFullscreen) && _unref(enterFullscreen)(...args))
|
|
226
|
-
}, [
|
|
227
|
-
_renderSlot(_ctx.$slots, "fullscreenEnterIcon", {}, () => [
|
|
228
|
-
_createVNode(IconFullscreenEnter)
|
|
229
|
-
])
|
|
230
|
-
]))
|
|
231
|
-
])
|
|
232
|
-
],
|
|
233
|
-
512
|
|
234
|
-
/* NEED_PATCH */
|
|
235
|
-
)
|
|
236
|
-
],
|
|
237
|
-
512
|
|
238
|
-
/* NEED_PATCH */
|
|
239
|
-
), [
|
|
240
|
-
[_vShow, !hidden.value]
|
|
241
|
-
])
|
|
242
|
-
]),
|
|
243
|
-
_: 3
|
|
244
|
-
/* FORWARDED */
|
|
245
|
-
}, 8, ["name"])
|
|
246
|
-
], 40, _hoisted_1);
|
|
247
|
-
};
|
|
109
|
+
standalone: {
|
|
110
|
+
type: Boolean,
|
|
111
|
+
required: false
|
|
112
|
+
},
|
|
113
|
+
transition: {
|
|
114
|
+
type: String,
|
|
115
|
+
required: false
|
|
248
116
|
}
|
|
249
117
|
});
|
|
118
|
+
const injectedInstanceId = inject(MagicPlayerInstanceId, void 0);
|
|
119
|
+
const mappedInstanceId = computed(() => id ?? injectedInstanceId);
|
|
120
|
+
if (!mappedInstanceId.value) {
|
|
121
|
+
throw new Error(
|
|
122
|
+
"MagicPlayerVideoControls must be nested inside MagicPlayerProvider or be passed an id as a prop."
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
const injectedOptions = inject(MagicPlayerOptionsKey, void 0);
|
|
126
|
+
const mappedTransition = computed(
|
|
127
|
+
() => transition ?? injectedOptions?.transition?.videoControls
|
|
128
|
+
);
|
|
129
|
+
const barRef = useTemplateRef("bar");
|
|
130
|
+
const trackRef = useTemplateRef("track");
|
|
131
|
+
const popoverRef = useTemplateRef("popover");
|
|
132
|
+
const { initializeState } = usePlayerState(mappedInstanceId.value);
|
|
133
|
+
const state = initializeState();
|
|
134
|
+
const {
|
|
135
|
+
playing,
|
|
136
|
+
waiting,
|
|
137
|
+
muted,
|
|
138
|
+
touched,
|
|
139
|
+
mouseEntered,
|
|
140
|
+
controlsMouseEntered,
|
|
141
|
+
isFullscreen,
|
|
142
|
+
popoverOffsetX,
|
|
143
|
+
seekedTime
|
|
144
|
+
} = toRefs(state);
|
|
145
|
+
const { play, pause, mute, unmute, enterFullscreen, exitFullscreen } = usePlayerVideoApi({ id: mappedInstanceId.value });
|
|
146
|
+
const { initialize, destroy, onMouseenter, onMouseleave } = usePlayerControlsApi({
|
|
147
|
+
id: mappedInstanceId.value,
|
|
148
|
+
barRef,
|
|
149
|
+
trackRef,
|
|
150
|
+
popoverRef
|
|
151
|
+
});
|
|
152
|
+
const elRef = useTemplateRef("el");
|
|
153
|
+
const isVisible = useElementVisibility(elRef);
|
|
154
|
+
const { idle } = useIdle(3e3);
|
|
155
|
+
const hidden = computed(() => {
|
|
156
|
+
switch (true) {
|
|
157
|
+
case standalone:
|
|
158
|
+
return false;
|
|
159
|
+
case (playing.value && idle.value):
|
|
160
|
+
return true;
|
|
161
|
+
case (playing.value && !controlsMouseEntered.value && !mouseEntered.value):
|
|
162
|
+
return true;
|
|
163
|
+
case !isVisible.value:
|
|
164
|
+
return true;
|
|
165
|
+
case !touched.value:
|
|
166
|
+
return true;
|
|
167
|
+
default:
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
initialize();
|
|
172
|
+
onBeforeUnmount(() => {
|
|
173
|
+
destroy();
|
|
174
|
+
});
|
|
175
|
+
provide(MagicPlayerInstanceId, mappedInstanceId.value);
|
|
176
|
+
provide(MagicPlayerTrackRef, trackRef);
|
|
177
|
+
provide(MagicPlayerPopoverRef, popoverRef);
|
|
178
|
+
provide(MagicPlayerBarRef, barRef);
|
|
250
179
|
</script>
|
|
@@ -9,7 +9,7 @@ export declare function useMagicPlayer(id: MaybeRef<string>): {
|
|
|
9
9
|
ended: import("vue").Ref<boolean, boolean>;
|
|
10
10
|
playing: import("vue").Ref<boolean, boolean>;
|
|
11
11
|
stalled: import("vue").Ref<boolean, boolean>;
|
|
12
|
-
buffered: import("vue").Ref<import("../types").Buffered, import("../types").Buffered>;
|
|
12
|
+
buffered: import("vue").Ref<import("../types/index.js").Buffered, import("../types/index.js").Buffered>;
|
|
13
13
|
muted: import("vue").Ref<boolean, boolean>;
|
|
14
14
|
touched: import("vue").Ref<boolean, boolean>;
|
|
15
15
|
dragging: import("vue").Ref<boolean, boolean>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="el" class="magic-scroll-collision">
|
|
3
|
+
<slot />
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup>
|
|
8
8
|
import {
|
|
9
9
|
shallowRef,
|
|
10
10
|
inject,
|
|
@@ -18,60 +18,50 @@ import {
|
|
|
18
18
|
import { useCollisionDetection } from "../composables/private/useCollisionDetection";
|
|
19
19
|
import { MagicScrollReturn, MagicScrollTarget } from "../symbols";
|
|
20
20
|
import { useIntersectionObserver } from "@vueuse/core";
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
offset: { type: Object, required: false }
|
|
21
|
+
const { id, offset } = defineProps({
|
|
22
|
+
id: {
|
|
23
|
+
type: String,
|
|
24
|
+
required: false
|
|
26
25
|
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
)
|
|
54
|
-
useIntersectionObserver(
|
|
55
|
-
elRef,
|
|
56
|
-
([{ isIntersecting }]) => {
|
|
57
|
-
intersecting.value = isIntersecting;
|
|
58
|
-
},
|
|
59
|
-
{ rootMargin: "150% 0px 150% 0px", immediate: true }
|
|
60
|
-
);
|
|
61
|
-
onMounted(() => {
|
|
26
|
+
offset: {
|
|
27
|
+
type: Object,
|
|
28
|
+
required: false
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const scrollReturn = inject(MagicScrollReturn, void 0);
|
|
32
|
+
const scrollTarget = inject(MagicScrollTarget);
|
|
33
|
+
if (!scrollTarget) {
|
|
34
|
+
console.error(
|
|
35
|
+
"MagicScrollCollision must be used within a MagicScrollProvider"
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
const intersecting = shallowRef(false);
|
|
39
|
+
const elRef = useTemplateRef("el");
|
|
40
|
+
const scrollY = computed(() => toValue(scrollReturn?.y) || 0);
|
|
41
|
+
const mappedId = computed(() => id ?? `magic-scroll-collision-${useId()}`);
|
|
42
|
+
const { observe } = useCollisionDetection({
|
|
43
|
+
id: mappedId.value,
|
|
44
|
+
child: elRef,
|
|
45
|
+
parent: scrollTarget,
|
|
46
|
+
scrollY,
|
|
47
|
+
offset
|
|
48
|
+
});
|
|
49
|
+
watch(
|
|
50
|
+
() => scrollY.value,
|
|
51
|
+
() => {
|
|
52
|
+
if (intersecting.value) {
|
|
62
53
|
observe();
|
|
63
|
-
}
|
|
64
|
-
return (_ctx, _cache) => {
|
|
65
|
-
return _openBlock(), _createElementBlock(
|
|
66
|
-
"div",
|
|
67
|
-
_hoisted_1,
|
|
68
|
-
[
|
|
69
|
-
_renderSlot(_ctx.$slots, "default")
|
|
70
|
-
],
|
|
71
|
-
512
|
|
72
|
-
/* NEED_PATCH */
|
|
73
|
-
);
|
|
74
|
-
};
|
|
54
|
+
}
|
|
75
55
|
}
|
|
56
|
+
);
|
|
57
|
+
useIntersectionObserver(
|
|
58
|
+
elRef,
|
|
59
|
+
([{ isIntersecting }]) => {
|
|
60
|
+
intersecting.value = isIntersecting;
|
|
61
|
+
},
|
|
62
|
+
{ rootMargin: "150% 0px 150% 0px", immediate: true }
|
|
63
|
+
);
|
|
64
|
+
onMounted(() => {
|
|
65
|
+
observe();
|
|
76
66
|
});
|
|
77
67
|
</script>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="el" class="magic-scroll-motion">
|
|
3
|
+
<slot />
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup>
|
|
8
8
|
import { ref, inject, computed, onMounted, watch, useTemplateRef } from "vue";
|
|
9
9
|
import { unrefElement } from "@vueuse/core";
|
|
10
10
|
import defu from "defu";
|
|
@@ -12,70 +12,63 @@ import {
|
|
|
12
12
|
animate
|
|
13
13
|
} from "motion";
|
|
14
14
|
import { MagicScrollProgress } from "../symbols";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
const { progress, sequence, sequenceOptions } = defineProps({
|
|
16
|
+
sequence: {
|
|
17
|
+
type: Array,
|
|
18
|
+
required: true
|
|
19
|
+
},
|
|
20
|
+
sequenceOptions: {
|
|
21
|
+
type: Object,
|
|
22
|
+
required: false
|
|
23
|
+
},
|
|
24
|
+
progress: {
|
|
25
|
+
type: Number,
|
|
26
|
+
required: false
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
const animation = ref(void 0);
|
|
30
|
+
const elRef = useTemplateRef("el");
|
|
31
|
+
const injectedProgress = inject(
|
|
32
|
+
MagicScrollProgress,
|
|
33
|
+
computed(() => 0)
|
|
34
|
+
);
|
|
35
|
+
const mappedProgress = computed(() => {
|
|
36
|
+
return progress || injectedProgress.value || 0;
|
|
37
|
+
});
|
|
38
|
+
const defaultSequenceOptions = {
|
|
39
|
+
duration: 1,
|
|
40
|
+
delay: 0
|
|
41
|
+
};
|
|
42
|
+
const mappedSequenceOptions = defu(sequenceOptions, defaultSequenceOptions);
|
|
43
|
+
function createAnimation() {
|
|
44
|
+
const el = unrefElement(elRef);
|
|
45
|
+
if (!sequence || !sequence.length || !el) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const mappedSequence = sequence.map((item) => {
|
|
49
|
+
const [animation2 = [], options = {}] = item;
|
|
50
|
+
return [el, animation2, options];
|
|
51
|
+
});
|
|
52
|
+
animation.value = animate(mappedSequence, mappedSequenceOptions);
|
|
53
|
+
animation.value.pause();
|
|
54
|
+
animation.value.time = mappedProgress.value;
|
|
55
|
+
}
|
|
56
|
+
watch(mappedProgress, (value) => {
|
|
57
|
+
if (!value && value !== 0 || !animation.value) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
animation.value.time = value;
|
|
61
|
+
});
|
|
62
|
+
watch(
|
|
63
|
+
() => sequence,
|
|
64
|
+
() => {
|
|
65
|
+
createAnimation();
|
|
21
66
|
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const elRef = useTemplateRef("el");
|
|
25
|
-
const injectedProgress = inject(
|
|
26
|
-
MagicScrollProgress,
|
|
27
|
-
computed(() => 0)
|
|
28
|
-
);
|
|
29
|
-
const mappedProgress = computed(() => {
|
|
30
|
-
return __props.progress || injectedProgress.value || 0;
|
|
31
|
-
});
|
|
32
|
-
const defaultSequenceOptions = {
|
|
33
|
-
duration: 1,
|
|
34
|
-
delay: 0
|
|
35
|
-
};
|
|
36
|
-
const mappedSequenceOptions = defu(__props.sequenceOptions, defaultSequenceOptions);
|
|
37
|
-
function createAnimation() {
|
|
38
|
-
const el = unrefElement(elRef);
|
|
39
|
-
if (!__props.sequence || !__props.sequence.length || !el) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const mappedSequence = __props.sequence.map((item) => {
|
|
43
|
-
const [animation2 = [], options = {}] = item;
|
|
44
|
-
return [el, animation2, options];
|
|
45
|
-
});
|
|
46
|
-
animation.value = animate(mappedSequence, mappedSequenceOptions);
|
|
47
|
-
animation.value.pause();
|
|
48
|
-
animation.value.time = mappedProgress.value;
|
|
49
|
-
}
|
|
50
|
-
watch(mappedProgress, (value) => {
|
|
51
|
-
if (!value && value !== 0 || !animation.value) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
animation.value.time = value;
|
|
55
|
-
});
|
|
56
|
-
watch(
|
|
57
|
-
() => __props.sequence,
|
|
58
|
-
() => {
|
|
59
|
-
createAnimation();
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
deep: true
|
|
63
|
-
}
|
|
64
|
-
);
|
|
65
|
-
onMounted(() => {
|
|
66
|
-
createAnimation();
|
|
67
|
-
});
|
|
68
|
-
return (_ctx, _cache) => {
|
|
69
|
-
return _openBlock(), _createElementBlock(
|
|
70
|
-
"div",
|
|
71
|
-
_hoisted_1,
|
|
72
|
-
[
|
|
73
|
-
_renderSlot(_ctx.$slots, "default")
|
|
74
|
-
],
|
|
75
|
-
512
|
|
76
|
-
/* NEED_PATCH */
|
|
77
|
-
);
|
|
78
|
-
};
|
|
67
|
+
{
|
|
68
|
+
deep: true
|
|
79
69
|
}
|
|
70
|
+
);
|
|
71
|
+
onMounted(() => {
|
|
72
|
+
createAnimation();
|
|
80
73
|
});
|
|
81
74
|
</script>
|