@@ -25,7 +25,9 @@ export type ResizeHandler<T extends Element = Element> = (
2525) => void ;
2626
2727export type Size = { width : number ; height : number } ;
28- export type NullableSize = { width : number ; height : number } | { width : null ; height : null } ;
28+ export type NullableSize =
29+ | { width : number ; height : number ; clientWidth : number ; clientHeight : number }
30+ | { width : null ; height : null ; clientWidth : null ; clientHeight : null } ;
2931
3032/**
3133 * Instantiate a new ResizeObserver that automatically get's disposed on cleanup.
@@ -139,7 +141,12 @@ export function createWindowSize(): Readonly<Size> {
139141export const useWindowSize : typeof createWindowSize =
140142 /*#__PURE__*/ createHydratableSingletonRoot ( createWindowSize ) ;
141143
142- const ELEMENT_SIZE_FALLBACK = { width : null , height : null } as const satisfies NullableSize ;
144+ const ELEMENT_SIZE_FALLBACK = {
145+ width : null ,
146+ height : null ,
147+ clientWidth : null ,
148+ clientHeight : null ,
149+ } as const satisfies NullableSize ;
143150
144151/**
145152 * @param target html element
@@ -150,7 +157,8 @@ export function getElementSize(target: Element | false | undefined | null): Null
150157 return { ...ELEMENT_SIZE_FALLBACK } ;
151158 }
152159 const { width, height } = target . getBoundingClientRect ( ) ;
153- return { width, height } ;
160+ const { clientWidth, clientHeight } = target ;
161+ return { width, height, clientWidth, clientHeight } ;
154162}
155163
156164/**
@@ -163,7 +171,7 @@ export function getElementSize(target: Element | false | undefined | null): Null
163171 * console.log(size.width, size.height)
164172 * })
165173 */
166- export function createElementSize ( target : Element ) : Readonly < Size > ;
174+ export function createElementSize ( target : Element ) : Readonly < NullableSize > ;
167175export function createElementSize (
168176 target : Accessor < Element | false | undefined | null > ,
169177) : Readonly < NullableSize > ;
0 commit comments