sard 1.0.29 → 1.1.0
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/all-components.js +2 -0
- package/components/danmaku/common.d.ts +38 -0
- package/components/danmaku/common.js +14 -0
- package/components/danmaku/danmaku.vue.d.ts +23 -0
- package/components/danmaku/danmaku.vue.js +370 -0
- package/components/danmaku/index.css +1 -0
- package/components/danmaku/index.d.ts +5 -0
- package/components/danmaku/index.js +6 -0
- package/components/index.d.ts +1 -0
- package/components/index.js +2 -1
- package/components/popover/common.js +1 -1
- package/components/preview-image/preview-image.vue.d.ts +1 -1
- package/global.d.ts +1 -0
- package/index.css +1 -1
- package/index.js +2 -1
- package/package.json +1 -1
package/all-components.js
CHANGED
|
@@ -25,6 +25,7 @@ import { CoolIcon } from "./components/cool-icon/index.js";
|
|
|
25
25
|
import { CountDown } from "./components/count-down/index.js";
|
|
26
26
|
import { CountTo } from "./components/count-to/index.js";
|
|
27
27
|
import { CropImage } from "./components/crop-image/index.js";
|
|
28
|
+
import { Danmaku } from "./components/danmaku/index.js";
|
|
28
29
|
import { DateStrip } from "./components/date-strip/index.js";
|
|
29
30
|
import { DatetimePicker } from "./components/datetime-picker/index.js";
|
|
30
31
|
import { DatetimePickerInput } from "./components/datetime-picker-input/index.js";
|
|
@@ -152,6 +153,7 @@ var all_components_default = {
|
|
|
152
153
|
CountDown,
|
|
153
154
|
CountTo,
|
|
154
155
|
CropImage,
|
|
156
|
+
Danmaku,
|
|
155
157
|
DateStrip,
|
|
156
158
|
DatetimePicker,
|
|
157
159
|
DatetimePickerInput,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type DefaultProps } from '../config';
|
|
2
|
+
export interface DanmakuProps<T> {
|
|
3
|
+
list?: T[];
|
|
4
|
+
rows?: number;
|
|
5
|
+
speed?: number;
|
|
6
|
+
/** 速度浮动范围 (px/s),每条弹幕在 [speed - speedRange, speed + speedRange] 内随机取速,0 表示不浮动 */
|
|
7
|
+
speedRange?: number;
|
|
8
|
+
gap?: number;
|
|
9
|
+
autoPlay?: boolean;
|
|
10
|
+
loop?: boolean;
|
|
11
|
+
/** 页面隐藏或滚出视口时自动暂停,默认开启 */
|
|
12
|
+
autoPause?: boolean;
|
|
13
|
+
/** 同时在飞弹幕数量上限,0 表示不限制 */
|
|
14
|
+
maxItems?: number;
|
|
15
|
+
/** 动画缓动函数 */
|
|
16
|
+
easing?: string;
|
|
17
|
+
/** 轨道高度,数字视为 px */
|
|
18
|
+
rowHeight?: number | string;
|
|
19
|
+
}
|
|
20
|
+
export declare const defaultDanmakuProps: DefaultProps<DanmakuProps<any>>;
|
|
21
|
+
export interface DanmakuSlots<T> {
|
|
22
|
+
item?(props: {
|
|
23
|
+
item: T;
|
|
24
|
+
index: number;
|
|
25
|
+
}): any;
|
|
26
|
+
}
|
|
27
|
+
export interface DanmakuEmits {
|
|
28
|
+
(e: 'play'): void;
|
|
29
|
+
(e: 'pause'): void;
|
|
30
|
+
(e: 'finish'): void;
|
|
31
|
+
}
|
|
32
|
+
export interface DanmakuExpose<T> {
|
|
33
|
+
play: () => void;
|
|
34
|
+
pause: () => void;
|
|
35
|
+
resume: () => void;
|
|
36
|
+
stop: () => void;
|
|
37
|
+
send: (item: T) => void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region packages/sard/components/danmaku/common.ts
|
|
2
|
+
const defaultDanmakuProps = {
|
|
3
|
+
rows: 3,
|
|
4
|
+
speed: 100,
|
|
5
|
+
speedRange: 0,
|
|
6
|
+
gap: 40,
|
|
7
|
+
autoPlay: true,
|
|
8
|
+
loop: false,
|
|
9
|
+
autoPause: true,
|
|
10
|
+
maxItems: 0,
|
|
11
|
+
easing: "linear"
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { defaultDanmakuProps };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type DanmakuProps, type DanmakuSlots, type DanmakuEmits, type DanmakuExpose } from './common';
|
|
2
|
+
declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
3
|
+
props: import("vue").PublicProps & __VLS_PrettifyLocal<DanmakuProps<T> & {
|
|
4
|
+
onPlay?: (() => any) | undefined;
|
|
5
|
+
onPause?: (() => any) | undefined;
|
|
6
|
+
onFinish?: (() => any) | undefined;
|
|
7
|
+
}> & (typeof globalThis extends {
|
|
8
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
9
|
+
} ? P : {});
|
|
10
|
+
expose: (exposed: import("vue").ShallowUnwrapRef<DanmakuExpose<T>>) => void;
|
|
11
|
+
attrs: any;
|
|
12
|
+
slots: DanmakuSlots<T>;
|
|
13
|
+
emit: DanmakuEmits;
|
|
14
|
+
}>) => import("vue").VNode & {
|
|
15
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
16
|
+
};
|
|
17
|
+
declare const _default: typeof __VLS_export;
|
|
18
|
+
export default _default;
|
|
19
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
20
|
+
[K in keyof T]: T[K];
|
|
21
|
+
} : {
|
|
22
|
+
[K in keyof T as K]: T[K];
|
|
23
|
+
}) & {};
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import { createBem, cssVarName } from "../../utils/bem.js";
|
|
2
|
+
import { addUnit } from "../../utils/utils.js";
|
|
3
|
+
import { useIntersectionObserver } from "../../use/useIntersectionObserver.js";
|
|
4
|
+
import { useResizeObserver } from "../../use/useResizeObserver.js";
|
|
5
|
+
import { useRtl } from "../../use/useRtl.js";
|
|
6
|
+
import { defaultDanmakuProps } from "./common.js";
|
|
7
|
+
import { Fragment, computed, createElementBlock, createTextVNode, defineComponent, mergeDefaults, nextTick, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, ref, renderList, renderSlot, toDisplayString, unref, useTemplateRef, watch } from "vue";
|
|
8
|
+
//#region packages/sard/components/danmaku/danmaku.vue
|
|
9
|
+
const _hoisted_1 = ["data-key"];
|
|
10
|
+
var danmaku_default = /*@__PURE__*/ defineComponent({
|
|
11
|
+
__name: "danmaku",
|
|
12
|
+
props: /*@__PURE__*/ mergeDefaults({
|
|
13
|
+
list: {
|
|
14
|
+
type: Array,
|
|
15
|
+
required: false
|
|
16
|
+
},
|
|
17
|
+
rows: {
|
|
18
|
+
type: Number,
|
|
19
|
+
required: false
|
|
20
|
+
},
|
|
21
|
+
speed: {
|
|
22
|
+
type: Number,
|
|
23
|
+
required: false
|
|
24
|
+
},
|
|
25
|
+
speedRange: {
|
|
26
|
+
type: Number,
|
|
27
|
+
required: false
|
|
28
|
+
},
|
|
29
|
+
gap: {
|
|
30
|
+
type: Number,
|
|
31
|
+
required: false
|
|
32
|
+
},
|
|
33
|
+
autoPlay: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
required: false
|
|
36
|
+
},
|
|
37
|
+
loop: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
required: false
|
|
40
|
+
},
|
|
41
|
+
autoPause: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
required: false
|
|
44
|
+
},
|
|
45
|
+
maxItems: {
|
|
46
|
+
type: Number,
|
|
47
|
+
required: false
|
|
48
|
+
},
|
|
49
|
+
easing: {
|
|
50
|
+
type: String,
|
|
51
|
+
required: false
|
|
52
|
+
},
|
|
53
|
+
rowHeight: {
|
|
54
|
+
type: [Number, String],
|
|
55
|
+
required: false
|
|
56
|
+
}
|
|
57
|
+
}, defaultDanmakuProps),
|
|
58
|
+
emits: [
|
|
59
|
+
"play",
|
|
60
|
+
"pause",
|
|
61
|
+
"finish"
|
|
62
|
+
],
|
|
63
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
64
|
+
const props = __props;
|
|
65
|
+
const emit = __emit;
|
|
66
|
+
const bem = createBem("danmaku");
|
|
67
|
+
const rootRef = useTemplateRef("root");
|
|
68
|
+
const tracks = ref([]);
|
|
69
|
+
const playing = ref(false);
|
|
70
|
+
const rootWidth = ref(0);
|
|
71
|
+
const isRtl = useRtl(rootRef);
|
|
72
|
+
const rootStyle = computed(() => {
|
|
73
|
+
const style = {};
|
|
74
|
+
if (props.rowHeight != null) style[cssVarName("danmaku-row-height")] = addUnit(props.rowHeight);
|
|
75
|
+
return style;
|
|
76
|
+
});
|
|
77
|
+
const queue = [];
|
|
78
|
+
const runtimeMap = /* @__PURE__ */ new Map();
|
|
79
|
+
const nextStartAt = [];
|
|
80
|
+
const pausedWaits = [];
|
|
81
|
+
let keySeq = 0;
|
|
82
|
+
let sendSeq = 0;
|
|
83
|
+
let finished = false;
|
|
84
|
+
let rafId = null;
|
|
85
|
+
let schedulerRunning = false;
|
|
86
|
+
const autoPaused = ref(false);
|
|
87
|
+
const pauseReasons = /* @__PURE__ */ new Set();
|
|
88
|
+
const containerWidth = () => {
|
|
89
|
+
return rootWidth.value || rootRef.value?.clientWidth || (typeof window !== "undefined" ? window.innerWidth : 0) || 375;
|
|
90
|
+
};
|
|
91
|
+
const queryBulletEl = (key) => {
|
|
92
|
+
return rootRef.value?.querySelector(`[data-key="${key}"]`) || null;
|
|
93
|
+
};
|
|
94
|
+
const defaultItemText = (item) => {
|
|
95
|
+
return typeof item === "string" || typeof item === "number" ? String(item) : "";
|
|
96
|
+
};
|
|
97
|
+
const cancelBullet = (runtime) => {
|
|
98
|
+
runtime.anim?.cancel();
|
|
99
|
+
runtime.anim = null;
|
|
100
|
+
};
|
|
101
|
+
const buildTracks = () => {
|
|
102
|
+
const count = Math.max(1, Math.round(props.rows));
|
|
103
|
+
tracks.value = Array.from({ length: count }, () => ({ bullets: [] }));
|
|
104
|
+
nextStartAt.length = 0;
|
|
105
|
+
pausedWaits.length = 0;
|
|
106
|
+
for (let i = 0; i < count; i++) {
|
|
107
|
+
nextStartAt.push(0);
|
|
108
|
+
pausedWaits.push(0);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const initQueue = () => {
|
|
112
|
+
queue.length = 0;
|
|
113
|
+
for (const [index, item] of (props.list || []).entries()) queue.push({
|
|
114
|
+
item,
|
|
115
|
+
index
|
|
116
|
+
});
|
|
117
|
+
finished = false;
|
|
118
|
+
for (let i = 0; i < pausedWaits.length; i++) pausedWaits[i] = 0;
|
|
119
|
+
};
|
|
120
|
+
const enqueue = (item, index) => {
|
|
121
|
+
queue.push({
|
|
122
|
+
item,
|
|
123
|
+
index
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
const dequeue = () => {
|
|
127
|
+
return queue.shift();
|
|
128
|
+
};
|
|
129
|
+
const clearAllBullets = () => {
|
|
130
|
+
for (const runtime of runtimeMap.values()) cancelBullet(runtime);
|
|
131
|
+
runtimeMap.clear();
|
|
132
|
+
for (const track of tracks.value) track.bullets = [];
|
|
133
|
+
for (let i = 0; i < nextStartAt.length; i++) nextStartAt[i] = 0;
|
|
134
|
+
};
|
|
135
|
+
const startBullet = (el, runtime) => {
|
|
136
|
+
const anim = el.animate([{ transform: `translate3d(${runtime.startX}px, -50%, 0)` }, { transform: `translate3d(${runtime.endX}px, -50%, 0)` }], {
|
|
137
|
+
duration: runtime.duration,
|
|
138
|
+
easing: props.easing
|
|
139
|
+
});
|
|
140
|
+
runtime.anim = anim;
|
|
141
|
+
runtime.state = "running";
|
|
142
|
+
anim.onfinish = () => {
|
|
143
|
+
finishBullet(runtime);
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
const pauseBullet = (runtime) => {
|
|
147
|
+
if (runtime.state !== "running") return;
|
|
148
|
+
runtime.anim?.pause();
|
|
149
|
+
runtime.state = "paused";
|
|
150
|
+
};
|
|
151
|
+
const resumeBullet = (runtime) => {
|
|
152
|
+
if (runtime.state !== "paused") return;
|
|
153
|
+
runtime.anim?.play();
|
|
154
|
+
runtime.state = "running";
|
|
155
|
+
};
|
|
156
|
+
const finishBullet = (runtime) => {
|
|
157
|
+
if (runtime.state === "done") return;
|
|
158
|
+
runtime.state = "done";
|
|
159
|
+
runtime.anim = null;
|
|
160
|
+
runtimeMap.delete(runtime.key);
|
|
161
|
+
const track = tracks.value[runtime.trackIndex];
|
|
162
|
+
const idx = track.bullets.findIndex((bullet) => bullet.key === runtime.key);
|
|
163
|
+
if (idx !== -1) track.bullets.splice(idx, 1);
|
|
164
|
+
if (props.loop) enqueue(runtime.entry.item, runtime.entry.index);
|
|
165
|
+
checkFinish();
|
|
166
|
+
};
|
|
167
|
+
const launch = async (trackIndex, entry) => {
|
|
168
|
+
const view = {
|
|
169
|
+
key: ++keySeq,
|
|
170
|
+
item: entry.item,
|
|
171
|
+
index: entry.index
|
|
172
|
+
};
|
|
173
|
+
const runtime = {
|
|
174
|
+
key: view.key,
|
|
175
|
+
trackIndex,
|
|
176
|
+
entry,
|
|
177
|
+
startX: 0,
|
|
178
|
+
endX: 0,
|
|
179
|
+
duration: 0,
|
|
180
|
+
anim: null,
|
|
181
|
+
state: "idle"
|
|
182
|
+
};
|
|
183
|
+
runtimeMap.set(view.key, runtime);
|
|
184
|
+
tracks.value[trackIndex].bullets.push(view);
|
|
185
|
+
nextStartAt[trackIndex] = Date.now() + 1e3;
|
|
186
|
+
await nextTick();
|
|
187
|
+
const el = queryBulletEl(view.key);
|
|
188
|
+
if (!el || runtime.state === "done") return;
|
|
189
|
+
const width = containerWidth();
|
|
190
|
+
const itemWidth = el.offsetWidth || 0;
|
|
191
|
+
const baseSpeed = props.speed > 0 ? props.speed : 100;
|
|
192
|
+
const speed = props.speedRange > 0 ? Math.max(1, baseSpeed + (Math.random() * 2 - 1) * props.speedRange) : baseSpeed;
|
|
193
|
+
runtime.startX = isRtl.value ? -itemWidth : width;
|
|
194
|
+
runtime.endX = isRtl.value ? width : -itemWidth;
|
|
195
|
+
runtime.duration = (width + itemWidth) / speed * 1e3;
|
|
196
|
+
nextStartAt[trackIndex] = Date.now() + (itemWidth + props.gap) / speed * 1e3;
|
|
197
|
+
startBullet(el, runtime);
|
|
198
|
+
if (!playing.value) pauseBullet(runtime);
|
|
199
|
+
};
|
|
200
|
+
const checkFinish = () => {
|
|
201
|
+
if (props.loop || queue.length > 0) return;
|
|
202
|
+
if (!tracks.value.some((track) => track.bullets.length > 0) && !finished) {
|
|
203
|
+
finished = true;
|
|
204
|
+
stopScheduler();
|
|
205
|
+
emit("finish");
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
const tick = () => {
|
|
209
|
+
if (!playing.value) return;
|
|
210
|
+
const now = Date.now();
|
|
211
|
+
const maxItems = props.maxItems > 0 ? props.maxItems : Infinity;
|
|
212
|
+
for (let i = 0; i < tracks.value.length; i++) {
|
|
213
|
+
if (queue.length === 0 || runtimeMap.size >= maxItems) break;
|
|
214
|
+
if (now >= nextStartAt[i]) {
|
|
215
|
+
const entry = dequeue();
|
|
216
|
+
if (entry) launch(i, entry);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if (queue.length === 0 && !props.loop) {
|
|
220
|
+
if (!tracks.value.some((track) => track.bullets.length > 0) && !finished) {
|
|
221
|
+
finished = true;
|
|
222
|
+
stopScheduler();
|
|
223
|
+
emit("finish");
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
const loop = () => {
|
|
228
|
+
if (!schedulerRunning) return;
|
|
229
|
+
tick();
|
|
230
|
+
if (schedulerRunning) rafId = requestAnimationFrame(loop);
|
|
231
|
+
};
|
|
232
|
+
const startScheduler = () => {
|
|
233
|
+
if (schedulerRunning) return;
|
|
234
|
+
schedulerRunning = true;
|
|
235
|
+
rafId = requestAnimationFrame(loop);
|
|
236
|
+
tick();
|
|
237
|
+
};
|
|
238
|
+
const stopScheduler = () => {
|
|
239
|
+
schedulerRunning = false;
|
|
240
|
+
if (rafId != null) {
|
|
241
|
+
cancelAnimationFrame(rafId);
|
|
242
|
+
rafId = null;
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
const resume = () => {
|
|
246
|
+
if (playing.value) return;
|
|
247
|
+
playing.value = true;
|
|
248
|
+
const now = Date.now();
|
|
249
|
+
for (let i = 0; i < nextStartAt.length; i++) {
|
|
250
|
+
nextStartAt[i] = now + (pausedWaits[i] ?? 0);
|
|
251
|
+
pausedWaits[i] = 0;
|
|
252
|
+
}
|
|
253
|
+
for (const runtime of runtimeMap.values()) if (runtime.state === "paused") resumeBullet(runtime);
|
|
254
|
+
startScheduler();
|
|
255
|
+
emit("play");
|
|
256
|
+
};
|
|
257
|
+
const play = () => {
|
|
258
|
+
if (finished && queue.length === 0) initQueue();
|
|
259
|
+
resume();
|
|
260
|
+
};
|
|
261
|
+
const pause = () => {
|
|
262
|
+
if (!playing.value) return;
|
|
263
|
+
playing.value = false;
|
|
264
|
+
const now = Date.now();
|
|
265
|
+
for (let i = 0; i < nextStartAt.length; i++) pausedWaits[i] = Math.max(0, nextStartAt[i] - now);
|
|
266
|
+
stopScheduler();
|
|
267
|
+
for (const runtime of runtimeMap.values()) if (runtime.state === "running") pauseBullet(runtime);
|
|
268
|
+
emit("pause");
|
|
269
|
+
};
|
|
270
|
+
const stop = () => {
|
|
271
|
+
playing.value = false;
|
|
272
|
+
autoPaused.value = false;
|
|
273
|
+
stopScheduler();
|
|
274
|
+
clearAllBullets();
|
|
275
|
+
initQueue();
|
|
276
|
+
};
|
|
277
|
+
const send = (item) => {
|
|
278
|
+
enqueue(item, sendSeq++);
|
|
279
|
+
if (playing.value) startScheduler();
|
|
280
|
+
};
|
|
281
|
+
const syncAutoPause = () => {
|
|
282
|
+
if (!props.autoPause) return;
|
|
283
|
+
if (pauseReasons.size > 0) {
|
|
284
|
+
if (playing.value) {
|
|
285
|
+
autoPaused.value = true;
|
|
286
|
+
pause();
|
|
287
|
+
}
|
|
288
|
+
} else if (autoPaused.value) {
|
|
289
|
+
autoPaused.value = false;
|
|
290
|
+
resume();
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
const onVisibilityChange = () => {
|
|
294
|
+
if (document.hidden) pauseReasons.add("hidden");
|
|
295
|
+
else pauseReasons.delete("hidden");
|
|
296
|
+
syncAutoPause();
|
|
297
|
+
};
|
|
298
|
+
const { isIntersecting } = useIntersectionObserver({
|
|
299
|
+
target: rootRef,
|
|
300
|
+
disabled: () => !props.autoPause
|
|
301
|
+
});
|
|
302
|
+
watch(isIntersecting, (value) => {
|
|
303
|
+
if (value) pauseReasons.delete("view");
|
|
304
|
+
else pauseReasons.add("view");
|
|
305
|
+
syncAutoPause();
|
|
306
|
+
}, { immediate: true });
|
|
307
|
+
__expose({
|
|
308
|
+
play,
|
|
309
|
+
pause,
|
|
310
|
+
resume,
|
|
311
|
+
stop,
|
|
312
|
+
send
|
|
313
|
+
});
|
|
314
|
+
onMounted(() => {
|
|
315
|
+
rootWidth.value = rootRef.value?.clientWidth || 0;
|
|
316
|
+
buildTracks();
|
|
317
|
+
initQueue();
|
|
318
|
+
document.addEventListener("visibilitychange", onVisibilityChange);
|
|
319
|
+
if (props.autoPlay) play();
|
|
320
|
+
});
|
|
321
|
+
onBeforeUnmount(() => {
|
|
322
|
+
stopScheduler();
|
|
323
|
+
document.removeEventListener("visibilitychange", onVisibilityChange);
|
|
324
|
+
for (const runtime of runtimeMap.values()) cancelBullet(runtime);
|
|
325
|
+
runtimeMap.clear();
|
|
326
|
+
});
|
|
327
|
+
useResizeObserver(rootRef, (size) => {
|
|
328
|
+
rootWidth.value = size.width;
|
|
329
|
+
});
|
|
330
|
+
watch(() => props.rows, () => {
|
|
331
|
+
const wasPlaying = playing.value;
|
|
332
|
+
stopScheduler();
|
|
333
|
+
clearAllBullets();
|
|
334
|
+
queue.length = 0;
|
|
335
|
+
buildTracks();
|
|
336
|
+
initQueue();
|
|
337
|
+
if (wasPlaying) startScheduler();
|
|
338
|
+
});
|
|
339
|
+
watch(() => props.list, () => {
|
|
340
|
+
const wasPlaying = playing.value;
|
|
341
|
+
stopScheduler();
|
|
342
|
+
clearAllBullets();
|
|
343
|
+
initQueue();
|
|
344
|
+
if (wasPlaying) startScheduler();
|
|
345
|
+
});
|
|
346
|
+
return (_ctx, _cache) => {
|
|
347
|
+
return openBlock(), createElementBlock("div", {
|
|
348
|
+
ref: "root",
|
|
349
|
+
class: normalizeClass(unref(bem).b()),
|
|
350
|
+
style: normalizeStyle(rootStyle.value)
|
|
351
|
+
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(tracks.value, (track, trackIndex) => {
|
|
352
|
+
return openBlock(), createElementBlock("div", {
|
|
353
|
+
key: trackIndex,
|
|
354
|
+
class: normalizeClass(unref(bem).e("track"))
|
|
355
|
+
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(track.bullets, (bullet) => {
|
|
356
|
+
return openBlock(), createElementBlock("div", {
|
|
357
|
+
key: bullet.key,
|
|
358
|
+
"data-key": bullet.key,
|
|
359
|
+
class: normalizeClass(unref(bem).e("item"))
|
|
360
|
+
}, [renderSlot(_ctx.$slots, "item", {
|
|
361
|
+
item: bullet.item,
|
|
362
|
+
index: bullet.index
|
|
363
|
+
}, () => [createTextVNode(toDisplayString(defaultItemText(bullet.item)), 1)])], 10, _hoisted_1);
|
|
364
|
+
}), 128))], 2);
|
|
365
|
+
}), 128))], 6);
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
//#endregion
|
|
370
|
+
export { danmaku_default as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root{--s-danmaku-row-height:34px}.s-danmaku{position:relative;overflow:hidden}.s-danmaku__track{position:relative;height:var(--s-danmaku-row-height)}.s-danmaku__item{position:absolute;top:50%;left:0;white-space:nowrap;will-change:transform;transform:translate3d(100vw, -50%, 0)}:root[dir=rtl] .s-danmaku__item{transform:translate3d(-100vw, -50%, 0)}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type EnhancedComponent } from '../../utils';
|
|
2
|
+
import _Danmaku from './danmaku.vue';
|
|
3
|
+
export declare const Danmaku: EnhancedComponent<typeof _Danmaku>;
|
|
4
|
+
export default Danmaku;
|
|
5
|
+
export type { DanmakuProps, DanmakuSlots, DanmakuEmits, DanmakuExpose } from './common';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { enhanceComponent } from "../../utils/component.js";
|
|
2
|
+
import danmaku_default from "./danmaku.vue.js";
|
|
3
|
+
//#region packages/sard/components/danmaku/index.ts
|
|
4
|
+
const Danmaku = enhanceComponent(danmaku_default);
|
|
5
|
+
//#endregion
|
|
6
|
+
export { Danmaku, Danmaku as default };
|
package/components/index.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export * from './cool-icon';
|
|
|
26
26
|
export * from './count-down';
|
|
27
27
|
export * from './count-to';
|
|
28
28
|
export * from './crop-image';
|
|
29
|
+
export * from './danmaku';
|
|
29
30
|
export * from './date-strip';
|
|
30
31
|
export * from './datetime-picker';
|
|
31
32
|
export * from './datetime-picker-input';
|
package/components/index.js
CHANGED
|
@@ -36,6 +36,7 @@ import { CountDown } from "./count-down/index.js";
|
|
|
36
36
|
import { CountTo } from "./count-to/index.js";
|
|
37
37
|
import { createCropImage, cropImage } from "./crop-image/imperative.js";
|
|
38
38
|
import { CropImage } from "./crop-image/index.js";
|
|
39
|
+
import { Danmaku } from "./danmaku/index.js";
|
|
39
40
|
import { DateStrip } from "./date-strip/index.js";
|
|
40
41
|
import { DatetimePicker } from "./datetime-picker/index.js";
|
|
41
42
|
import { DatetimePickerInput } from "./datetime-picker-input/index.js";
|
|
@@ -140,4 +141,4 @@ import { Tree, TreeBranch, TreeNode } from "./tree/index.js";
|
|
|
140
141
|
import { Upload, UploadPreview } from "./upload/index.js";
|
|
141
142
|
import { Waterfall, WaterfallItem, WaterfallLoad } from "./waterfall/index.js";
|
|
142
143
|
import { Watermark } from "./watermark/index.js";
|
|
143
|
-
export { ADD_SWIPER_CONTEXT_KEY, Accordion, AccordionItem, ActionSheet, ActionSheetItem, Alert, Avatar, AvatarGroup, BackTop, Badge, Barcode, Button, Calendar, CalendarInput, CalendarPopout, CancelError, Card, Cascader, CascaderInput, CascaderPopout, Checkbox, CheckboxGroup, CheckboxInput, CheckboxPopout, Col, Collapse, ColorPicker, ColorPickerInput, ColorPickerPopout, Compact, CoolIcon, CountDown, CountTo, CropImage, DateStrip, DatetimePicker, DatetimePickerInput, DatetimePickerPopout, DatetimeRangePicker, DatetimeRangePickerInput, DatetimeRangePickerPopout, Descriptions, DescriptionsItem, Dialog, Divider, Dnd, DndHandle, DndItem, Dropdown, DropdownItem, Ellipsis, Empty, Fab, FabItem, Flex, FloatingBubble, FloatingPanel, Form, FormItem, FormItemPlain, FormPlain, Grid, GridItem, Image, Indexes, IndexesAnchor, IndexesNav, Input, Keyboard, KeyboardPopout, List, ListItem, LoadMore, LoadMoreStatus, Loading, Marquee, Menu, MenuItem, Motion, Navbar, NavbarItem, NavbarPit, NoticeBar, Notify, Overlay, Pagination, PasswordInput, Picker, PickerInput, PickerPopout, PickerView, PickerViewColumn, Popout, PopoutInput, Popover, Popup, PreviewImage, ProgressBar, ProgressCircle, PullDownRefresh, PuzzleVerify, Qrcode, REMOVE_SWIPER_CONTEXT_KEY, Radio, RadioGroup, RadioInput, RadioPopout, Rate, ReadMore, Result, RotateVerify, Row, SWIPER_AUTO_HEIGHT_KEY, ScrollList, ScrollSpy, ScrollSpyAnchor, Search, Segmented, SegmentedItem, Select, SelectInput, SelectOption, SelectOptionGroup, SelectPopout, ShareSheet, ShareSheetIcon, ShareSheetItem, ShareSheetRow, Sidebar, SidebarItem, Signature, Skeleton, SkeletonAvatar, SkeletonBlock, SkeletonParagraph, SkeletonTitle, SlideVerify, Slider, StatusBar, Step, Stepper, Steps, Sticky, StickyBox, SwipeAction, Swiper, SwiperItem, Switch, Tab, Tabbar, TabbarItem, TabbarPit, Table, Tabs, Tag, Text, Timeline, TimelineItem, Toast, Tree, TreeBranch, TreeNode, Upload, UploadPreview, Waterfall, WaterfallItem, WaterfallLoad, Watermark, actionSheet, createActionSheet, createCropImage, createDialog, createNotify, createPreviewImage, createToast, cropImage, dialog, flexGap, formatTime, getCurrentTime, isCancelError, notify, omitFormPopoutProps, partitionPopoutInputProps, plateEnglishLetterKeys, plateProvinceKeys, plateSuffixKeys, popupManager, previewImage, safeAreaInsets, toast, useCountDown, useElementBackTop, useFormContext, useFormItem, useFormItemContext, useFormPopout, useInPopup, useMotioning, usePageBackTop, usePopoutInput, usePopupEnter, usePopupVisibleHookProvide, windowInfo };
|
|
144
|
+
export { ADD_SWIPER_CONTEXT_KEY, Accordion, AccordionItem, ActionSheet, ActionSheetItem, Alert, Avatar, AvatarGroup, BackTop, Badge, Barcode, Button, Calendar, CalendarInput, CalendarPopout, CancelError, Card, Cascader, CascaderInput, CascaderPopout, Checkbox, CheckboxGroup, CheckboxInput, CheckboxPopout, Col, Collapse, ColorPicker, ColorPickerInput, ColorPickerPopout, Compact, CoolIcon, CountDown, CountTo, CropImage, Danmaku, DateStrip, DatetimePicker, DatetimePickerInput, DatetimePickerPopout, DatetimeRangePicker, DatetimeRangePickerInput, DatetimeRangePickerPopout, Descriptions, DescriptionsItem, Dialog, Divider, Dnd, DndHandle, DndItem, Dropdown, DropdownItem, Ellipsis, Empty, Fab, FabItem, Flex, FloatingBubble, FloatingPanel, Form, FormItem, FormItemPlain, FormPlain, Grid, GridItem, Image, Indexes, IndexesAnchor, IndexesNav, Input, Keyboard, KeyboardPopout, List, ListItem, LoadMore, LoadMoreStatus, Loading, Marquee, Menu, MenuItem, Motion, Navbar, NavbarItem, NavbarPit, NoticeBar, Notify, Overlay, Pagination, PasswordInput, Picker, PickerInput, PickerPopout, PickerView, PickerViewColumn, Popout, PopoutInput, Popover, Popup, PreviewImage, ProgressBar, ProgressCircle, PullDownRefresh, PuzzleVerify, Qrcode, REMOVE_SWIPER_CONTEXT_KEY, Radio, RadioGroup, RadioInput, RadioPopout, Rate, ReadMore, Result, RotateVerify, Row, SWIPER_AUTO_HEIGHT_KEY, ScrollList, ScrollSpy, ScrollSpyAnchor, Search, Segmented, SegmentedItem, Select, SelectInput, SelectOption, SelectOptionGroup, SelectPopout, ShareSheet, ShareSheetIcon, ShareSheetItem, ShareSheetRow, Sidebar, SidebarItem, Signature, Skeleton, SkeletonAvatar, SkeletonBlock, SkeletonParagraph, SkeletonTitle, SlideVerify, Slider, StatusBar, Step, Stepper, Steps, Sticky, StickyBox, SwipeAction, Swiper, SwiperItem, Switch, Tab, Tabbar, TabbarItem, TabbarPit, Table, Tabs, Tag, Text, Timeline, TimelineItem, Toast, Tree, TreeBranch, TreeNode, Upload, UploadPreview, Waterfall, WaterfallItem, WaterfallLoad, Watermark, actionSheet, createActionSheet, createCropImage, createDialog, createNotify, createPreviewImage, createToast, cropImage, dialog, flexGap, formatTime, getCurrentTime, isCancelError, notify, omitFormPopoutProps, partitionPopoutInputProps, plateEnglishLetterKeys, plateProvinceKeys, plateSuffixKeys, popupManager, previewImage, safeAreaInsets, toast, useCountDown, useElementBackTop, useFormContext, useFormItem, useFormItemContext, useFormPopout, useInPopup, useMotioning, usePageBackTop, usePopoutInput, usePopupEnter, usePopupVisibleHookProvide, windowInfo };
|
|
@@ -28,10 +28,10 @@ declare const __VLS_base: import("vue").DefineComponent<PreviewImageProps, Previ
|
|
|
28
28
|
}>, {
|
|
29
29
|
visible: boolean;
|
|
30
30
|
closeOnBackPress: boolean;
|
|
31
|
+
loop: boolean;
|
|
31
32
|
current: number;
|
|
32
33
|
urls: string[];
|
|
33
34
|
showIndicator: boolean;
|
|
34
|
-
loop: boolean;
|
|
35
35
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
36
36
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
37
37
|
declare const _default: typeof __VLS_export;
|
package/global.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ declare module 'vue' {
|
|
|
32
32
|
SCountDown: typeof import('./components/count-down/count-down').default
|
|
33
33
|
SCountTo: typeof import('./components/count-to/count-to').default
|
|
34
34
|
SCropImage: typeof import('./components/crop-image/crop-image').default
|
|
35
|
+
SDanmaku: typeof import('./components/danmaku/danmaku').default
|
|
35
36
|
SDateStrip: typeof import('./components/date-strip/date-strip').default
|
|
36
37
|
SDatetimePicker: typeof import('./components/datetime-picker/datetime-picker').default
|
|
37
38
|
SDatetimePickerInput: typeof import('./components/datetime-picker-input/datetime-picker-input').default
|