DOM element utilities: computed styles, scroll control, resize observation, flash animation, and scroll-to-view
Gets the computed style value of an element using window.getComputedStyle(). Returns the value as a string, or null if the element is not found.
Disables page scrolling while preserving scrollbar space via paddingRight. Supports nested calls — scroll is only re-enabled when all callers have called enableScroll().
Calculates the browser scrollbar width in pixels. The result is cached after the first call.
Briefly flashes the element with a background highlight animation (.is-flashing + sdrzm-flash keyframes). The class is removed automatically on animationend.
Smoothly scrolls the page to bring the target element into view. Accepts an optional margin (default: 10px) for top offset. Prevents over-scrolling past page boundaries.
Observes an element for resize events using ResizeObserver. Returns the observer instance — call .disconnect() to stop observing.
Run Sadrazam.Elem.help() in the browser console to see all available methods and their descriptions.
All static methods available on Sadrazam.Elem
| Method | Parameters | Returns | Description |
|---|---|---|---|
| getStyle(el, styleProp) | el: HTMLElement, styleProp: string | string | null | Gets the computed style value of an element. |
| disableScroll() | — | void | Disables page scrolling. Supports nested calls. |
| enableScroll() | — | void | Re-enables page scrolling. Must be called once per disableScroll(). |
| getScrollbarWidth() | — | number | Calculates the browser scrollbar width in pixels (cached). |
| flash(element) | element: HTMLElement | void | Briefly flashes the element with a background highlight. |
| scrollToView(el, options?) | el: HTMLElement, options?: { margin: number } | void | Smoothly scrolls the page to the specified element. Default margin: 10px. |
| onElementHeightChange(el, cb) | el: HTMLElement, cb: function | ResizeObserver | null | Runs a callback when the element is resized. Returns the observer instance. |
| help() | — | void | Prints available methods to the console. |