fn

setStyle

v0.0.5

Applies 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 restored

Signature

ts
declare function setStyle(element?: Element | HTMLElement | null, styles?: StylePatch, ignoreCache?: boolean): void;

Parameters

ParameterTypeDescription
element?Element | HTMLElement | nullThe element to style (ignored if not an HTMLElement)
styles?StylePatchThe property/value pairs to apply
ignoreCache?booleanSkip remembering the overwritten values