mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-08-02 17:57:45 +03:00
refactor(web-test): replace fade transitions with auto-cleanup of overlays
CSS fade transitions don't work well with CDP screencast (causes desktop flash between slides). Instead, showImage/showTitleSlide now automatically remove the other overlay type — no need to call hide before showing next. Pattern for consecutive slides: showTitleSlide(...) → showImage(...) → showImage(...) → hideImage() No hideTitleSlide() needed between title and first image. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
b7e3bd876d
commit
14b0782904
@@ -4213,8 +4213,7 @@ export async function showTitleSlide(text, opts = {}) {
|
|||||||
|
|
||||||
await page.evaluate(({ text, subtitle, background, color, fontSize }) => {
|
await page.evaluate(({ text, subtitle, background, color, fontSize }) => {
|
||||||
let div = document.getElementById('__web_test_title');
|
let div = document.getElementById('__web_test_title');
|
||||||
const isNew = !div;
|
if (!div) {
|
||||||
if (isNew) {
|
|
||||||
div = document.createElement('div');
|
div = document.createElement('div');
|
||||||
div.id = '__web_test_title';
|
div.id = '__web_test_title';
|
||||||
document.body.appendChild(div);
|
document.body.appendChild(div);
|
||||||
@@ -4224,15 +4223,16 @@ export async function showTitleSlide(text, opts = {}) {
|
|||||||
`background:${background}`,
|
`background:${background}`,
|
||||||
'display:flex', 'align-items:center', 'justify-content:center',
|
'display:flex', 'align-items:center', 'justify-content:center',
|
||||||
'z-index:999999', 'pointer-events:none',
|
'z-index:999999', 'pointer-events:none',
|
||||||
'transition:opacity 0.3s ease', isNew ? 'opacity:0' : ''
|
|
||||||
].join(';');
|
].join(';');
|
||||||
|
// Remove other overlays to prevent flash between slides
|
||||||
|
const img = document.getElementById('__web_test_image');
|
||||||
|
if (img) img.remove();
|
||||||
const esc = s => s.replace(/&/g, '&').replace(/</g, '<').replace(/\n/g, '<br>');
|
const esc = s => s.replace(/&/g, '&').replace(/</g, '<').replace(/\n/g, '<br>');
|
||||||
let html = `<div style="font-size:${fontSize}px;font-weight:600;line-height:1.4;">${esc(text)}</div>`;
|
let html = `<div style="font-size:${fontSize}px;font-weight:600;line-height:1.4;">${esc(text)}</div>`;
|
||||||
if (subtitle) {
|
if (subtitle) {
|
||||||
html += `<div style="font-size:${Math.round(fontSize * 0.5)}px;margin-top:16px;opacity:0.7;">${esc(subtitle)}</div>`;
|
html += `<div style="font-size:${Math.round(fontSize * 0.5)}px;margin-top:16px;opacity:0.7;">${esc(subtitle)}</div>`;
|
||||||
}
|
}
|
||||||
div.innerHTML = `<div style="text-align:center;max-width:70%;color:${color};font-family:'Segoe UI',Arial,sans-serif;">${html}</div>`;
|
div.innerHTML = `<div style="text-align:center;max-width:70%;color:${color};font-family:'Segoe UI',Arial,sans-serif;">${html}</div>`;
|
||||||
if (isNew) requestAnimationFrame(() => { div.style.opacity = '1'; });
|
|
||||||
}, { text, subtitle, background, color, fontSize });
|
}, { text, subtitle, background, color, fontSize });
|
||||||
|
|
||||||
// Smart TTS wait (same pattern as showCaption/showImage)
|
// Smart TTS wait (same pattern as showCaption/showImage)
|
||||||
@@ -4248,22 +4248,13 @@ export async function showTitleSlide(text, opts = {}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Remove the title slide overlay (with fade-out). */
|
/** Remove the title slide overlay. */
|
||||||
export async function hideTitleSlide() {
|
export async function hideTitleSlide() {
|
||||||
ensureConnected();
|
ensureConnected();
|
||||||
const exists = await page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
const el = document.getElementById('__web_test_title');
|
const el = document.getElementById('__web_test_title');
|
||||||
if (!el) return false;
|
if (el) el.remove();
|
||||||
el.style.opacity = '0';
|
|
||||||
return true;
|
|
||||||
});
|
});
|
||||||
if (exists) {
|
|
||||||
await page.waitForTimeout(350);
|
|
||||||
await page.evaluate(() => {
|
|
||||||
const el = document.getElementById('__web_test_title');
|
|
||||||
if (el) el.remove();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -4337,18 +4328,20 @@ export async function showImage(imagePath, opts = {}) {
|
|||||||
|
|
||||||
await page.evaluate(({ dataUrl, fit, bg, useBlur, shadow, maxSize, isFull }) => {
|
await page.evaluate(({ dataUrl, fit, bg, useBlur, shadow, maxSize, isFull }) => {
|
||||||
let div = document.getElementById('__web_test_image');
|
let div = document.getElementById('__web_test_image');
|
||||||
const isNew = !div;
|
if (!div) {
|
||||||
if (isNew) {
|
|
||||||
div = document.createElement('div');
|
div = document.createElement('div');
|
||||||
div.id = '__web_test_image';
|
div.id = '__web_test_image';
|
||||||
document.body.appendChild(div);
|
document.body.appendChild(div);
|
||||||
}
|
}
|
||||||
|
// Remove other overlays to prevent flash between slides
|
||||||
|
const title = document.getElementById('__web_test_title');
|
||||||
|
if (title) title.remove();
|
||||||
|
|
||||||
div.style.cssText = [
|
div.style.cssText = [
|
||||||
'position:fixed', 'top:0', 'left:0', 'width:100%', 'height:100%',
|
'position:fixed', 'top:0', 'left:0', 'width:100%', 'height:100%',
|
||||||
`background:${bg}`,
|
`background:${bg}`,
|
||||||
'display:flex', 'align-items:center', 'justify-content:center',
|
'display:flex', 'align-items:center', 'justify-content:center',
|
||||||
'z-index:999999', 'pointer-events:none', 'overflow:hidden',
|
'z-index:999999', 'pointer-events:none', 'overflow:hidden'
|
||||||
'transition:opacity 0.3s ease', isNew ? 'opacity:0' : ''
|
|
||||||
].join(';');
|
].join(';');
|
||||||
|
|
||||||
let html = '';
|
let html = '';
|
||||||
@@ -4366,7 +4359,6 @@ export async function showImage(imagePath, opts = {}) {
|
|||||||
html += `<img src="${dataUrl}" style="position:relative;${sizeCss}${shadowCss}" />`;
|
html += `<img src="${dataUrl}" style="position:relative;${sizeCss}${shadowCss}" />`;
|
||||||
|
|
||||||
div.innerHTML = html;
|
div.innerHTML = html;
|
||||||
if (isNew) requestAnimationFrame(() => { div.style.opacity = '1'; });
|
|
||||||
}, { dataUrl, fit, bg, useBlur, shadow, maxSize, isFull });
|
}, { dataUrl, fit, bg, useBlur, shadow, maxSize, isFull });
|
||||||
|
|
||||||
// Smart TTS wait (same pattern as showCaption)
|
// Smart TTS wait (same pattern as showCaption)
|
||||||
@@ -4382,22 +4374,13 @@ export async function showImage(imagePath, opts = {}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Remove the image overlay (with fade-out). */
|
/** Remove the image overlay. */
|
||||||
export async function hideImage() {
|
export async function hideImage() {
|
||||||
ensureConnected();
|
ensureConnected();
|
||||||
const exists = await page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
const el = document.getElementById('__web_test_image');
|
const el = document.getElementById('__web_test_image');
|
||||||
if (!el) return false;
|
if (el) el.remove();
|
||||||
el.style.opacity = '0';
|
|
||||||
return true;
|
|
||||||
});
|
});
|
||||||
if (exists) {
|
|
||||||
await page.waitForTimeout(350);
|
|
||||||
await page.evaluate(() => {
|
|
||||||
const el = document.getElementById('__web_test_image');
|
|
||||||
if (el) el.remove();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user