Commit 7c88890f authored by Alejandro Celaya's avatar Alejandro Celaya Committed by Alejandro Celaya

Migrate observe-element-size module to TS

parent 6df3b42d
......@@ -7,13 +7,14 @@ import { ListenerCollection } from '../../shared/listener-collection';
* Returns a cleanup function which should be called to remove observers when
* updates are no longer needed.
*
* @param {Element} element - HTML element to watch
* @param {(width: number, height: number) => void} onSizeChanged -
* Callback to invoke with the `clientWidth` and `clientHeight` of the
* element when a change in its size is detected.
* @return {() => void}
* @param element - HTML element to watch
* @param onSizeChanged - Callback to invoke with the `clientWidth` and
* `clientHeight` of the element when a change in its size is detected.
*/
export function observeElementSize(element, onSizeChanged) {
export function observeElementSize(
element: Element,
onSizeChanged: (width: number, height: number) => void
): () => void {
if (typeof ResizeObserver !== 'undefined') {
const observer = new ResizeObserver(() =>
onSizeChanged(element.clientWidth, element.clientHeight)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment