fix: enforce handbook scrollbar and reduced motion contracts
This commit is contained in:
@@ -40,12 +40,22 @@ export function useOverlayAnimation(
|
||||
if (!animation || animation === "none") entering.value = false;
|
||||
};
|
||||
const observer = new MutationObserver(check);
|
||||
observer.observe(el, { attributes: true, attributeFilter: ["style"] });
|
||||
if (floating && wrapper)
|
||||
observer.observe(wrapper, {
|
||||
observer.observe(el, {
|
||||
attributes: true,
|
||||
attributeFilter: ["data-reduce-motion", "class", "style"],
|
||||
});
|
||||
// Reduced motion can change on a theme/portal ancestor while an entrance
|
||||
// runs. A cancelled animation has no animationend to clear its marker.
|
||||
for (
|
||||
let ancestor = el.parentElement;
|
||||
ancestor;
|
||||
ancestor = ancestor.parentElement
|
||||
)
|
||||
observer.observe(ancestor, {
|
||||
attributes: true,
|
||||
attributeFilter: ["style"],
|
||||
attributeFilter: ["data-reduce-motion", "class", "style"],
|
||||
});
|
||||
el.addEventListener("animationcancel", check);
|
||||
const media = el.ownerDocument.defaultView?.matchMedia?.(
|
||||
"(prefers-reduced-motion: reduce)",
|
||||
);
|
||||
@@ -54,6 +64,7 @@ export function useOverlayAnimation(
|
||||
onCleanup(() => {
|
||||
stale = true;
|
||||
observer.disconnect();
|
||||
el.removeEventListener("animationcancel", check);
|
||||
media?.removeEventListener("change", check);
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user