mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-16 06:19:21 +00:00
fix(core): a canvas in a blurred composition stays where it was laid out (#6975)
* fix(core): a canvas in a blurred composition stays where it was laid out drawElementImage drops a nested canvas's layout offset unless the canvas has a transform, so with capture blur on, `top: 200px` painted at 0. A zero `translate` while captured is enough, and leaves `top`, the composition's own `transform` and its `translate` alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(core): give the nested canvas rule no specificity A class on a composition's canvas lost to the rule, so its own `translate` was dropped while captured. Under `:where()` any composition rule wins. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
01c0bf4962
commit
2bdc866c85
@@ -681,6 +681,18 @@ const HIDE = "data-hf-motion-blur-hide";
|
||||
const ONLY = "data-hf-motion-blur-only";
|
||||
const MOVER = "data-hf-motion-blur-mover";
|
||||
|
||||
describe("a canvas inside the composition", () => {
|
||||
// Chrome drops a nested canvas's layout offset from drawElementImage unless it has a transform.
|
||||
it("gets a transform while captured, one the composition's own translate overrides", () => {
|
||||
installHtmlInCanvas();
|
||||
const { h } = movingHost({ "data-motion-blur": "on" });
|
||||
initCaptureMotionBlur(h);
|
||||
void paintCaptureMotionBlur(0.1, PLAY);
|
||||
const rules = [...document.head.querySelectorAll("style")].map((s) => s.textContent).join("\n");
|
||||
expect(rules).toContain(`:where([data-hf-motion-blur="capture"] canvas) { translate: 0 0 0; }`);
|
||||
});
|
||||
});
|
||||
|
||||
describe("two-phase frames", () => {
|
||||
it("hides the movers for a background capture, then reveals them and settles", async () => {
|
||||
installHtmlInCanvas();
|
||||
|
||||
@@ -65,6 +65,7 @@ const HIDE_ATTR = "data-hf-motion-blur-hide";
|
||||
/** On the root while the movers alone are captured; the movers carry MOVER_ATTR. */
|
||||
const ONLY_ATTR = "data-hf-motion-blur-only";
|
||||
const MOVER_ATTR = "data-hf-motion-blur-mover";
|
||||
const NESTED_CANVAS_KEEPS_ITS_PLACE = `:where([data-hf-motion-blur="capture"] canvas) { translate: 0 0 0; }`;
|
||||
|
||||
interface Job {
|
||||
seq: number;
|
||||
@@ -170,6 +171,7 @@ function createInstance(host: CaptureMotionBlurHost, config: Config, form: HtmlI
|
||||
`[${ONLY_ATTR}] { background: none !important; border-color: transparent !important; box-shadow: none !important; outline-color: transparent !important; }`,
|
||||
`[${ONLY_ATTR}]::before, [${ONLY_ATTR}]::after, [${ONLY_ATTR}] *:not([${MOVER_ATTR}], [${MOVER_ATTR}] *) { visibility: hidden !important; }`,
|
||||
`[${ONLY_ATTR}] [${MOVER_ATTR}] { visibility: visible !important; }`,
|
||||
NESTED_CANVAS_KEEPS_ITS_PLACE,
|
||||
].join("\n");
|
||||
|
||||
let movers: HTMLElement[] = [];
|
||||
|
||||
Reference in New Issue
Block a user