mirror of
https://github.com/OpenVGLab/OmniLottie.git
synced 2026-09-17 07:36:27 +00:00
modify lottie player and demo video interval
This commit is contained in:
+7
-13
@@ -739,12 +739,12 @@
|
|||||||
const buttons = [...document.querySelectorAll('#overlayControls .overlay-btn')];
|
const buttons = [...document.querySelectorAll('#overlayControls .overlay-btn')];
|
||||||
if (!videos.length || !buttons.length) return;
|
if (!videos.length || !buttons.length) return;
|
||||||
|
|
||||||
const switchTo = (index) => {
|
const switchTo = (index, fromStart = false) => {
|
||||||
videos.forEach((video, i) => {
|
videos.forEach((video, i) => {
|
||||||
const active = i === index;
|
const active = i === index;
|
||||||
video.classList.toggle('active', active);
|
video.classList.toggle('active', active);
|
||||||
if (active) {
|
if (active) {
|
||||||
video.currentTime = video.currentTime || 0;
|
if (fromStart) video.currentTime = 0;
|
||||||
video.play().catch(() => {});
|
video.play().catch(() => {});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -759,13 +759,13 @@
|
|||||||
overlayTimer = setInterval(() => {
|
overlayTimer = setInterval(() => {
|
||||||
current = (current + 1) % videos.length;
|
current = (current + 1) % videos.length;
|
||||||
switchTo(current);
|
switchTo(current);
|
||||||
}, 4500);
|
}, 10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
buttons.forEach((button) => {
|
buttons.forEach((button) => {
|
||||||
button.addEventListener('click', () => {
|
button.addEventListener('click', () => {
|
||||||
const idx = Number(button.dataset.index || 0);
|
const idx = Number(button.dataset.index || 0);
|
||||||
switchTo(idx);
|
switchTo(idx, true);
|
||||||
restartTimer(idx);
|
restartTimer(idx);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -851,13 +851,7 @@
|
|||||||
const canvas = document.createElement('div');
|
const canvas = document.createElement('div');
|
||||||
canvas.className = 'lottie-canvas';
|
canvas.className = 'lottie-canvas';
|
||||||
|
|
||||||
const label = document.createElement('div');
|
|
||||||
label.className = 'lottie-name';
|
|
||||||
label.textContent = prettyName(file);
|
|
||||||
label.title = prettyName(file);
|
|
||||||
|
|
||||||
card.appendChild(canvas);
|
card.appendChild(canvas);
|
||||||
card.appendChild(label);
|
|
||||||
|
|
||||||
const animation = window.lottie.loadAnimation({
|
const animation = window.lottie.loadAnimation({
|
||||||
container: canvas,
|
container: canvas,
|
||||||
@@ -960,7 +954,7 @@
|
|||||||
|
|
||||||
const { files, baseDir, source } = await loadAllJsonFiles();
|
const { files, baseDir, source } = await loadAllJsonFiles();
|
||||||
if (!files.length) {
|
if (!files.length) {
|
||||||
statusEl.textContent = '未找到 JSON 资源,请检查 assets/demo_new_set 目录或 manifest.json';
|
statusEl.textContent = 'No Lottie files found, please check the assets/demo_new_set directory or manifest.json';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -988,10 +982,10 @@
|
|||||||
try {
|
try {
|
||||||
await navigator.clipboard.writeText(text);
|
await navigator.clipboard.writeText(text);
|
||||||
btn.textContent = '已复制';
|
btn.textContent = '已复制';
|
||||||
setTimeout(() => { btn.textContent = '复制 Citation'; }, 1200);
|
setTimeout(() => { btn.textContent = 'Copied Citation'; }, 1200);
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
btn.textContent = '复制失败';
|
btn.textContent = '复制失败';
|
||||||
setTimeout(() => { btn.textContent = '复制 Citation'; }, 1200);
|
setTimeout(() => { btn.textContent = 'Copied Citation'; }, 1200);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user