fn
setStyle
v0.0.5testedApplies a batch of inline styles to an element, remembering the
values it overwrote so resetStyle can restore them later. --custom
properties are written through setProperty. Pass ignoreCache to apply the
styles without recording the originals (e.g. for transient, per-frame writes
during a drag that you intend to clear wholesale).
Example
ts
setStyle(el, { transition: 'none', transform: 'translateY(20px)' });
setStyle(el, { opacity: '0.5' }, true); // transient — won't be restoredSignature
ts
export function setStyle(element?: Element | HTMLElement | null, styles?: StylePatch, ignoreCache = false): void{ ... }Parameters
| Parameter | Type | Description |
|---|---|---|
element? | Element | HTMLElement | null | The element to style (ignored if not an HTMLElement) |
styles? | StylePatch | The property/value pairs to apply |
ignoreCache? | boolean | Skip remembering the overwritten values |