@@ -25,7 +25,10 @@ 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+ type SizeWithClient = Size & { clientWidth : number ; clientHeight : number } ;
29+ export type NullableSize =
30+ | SizeWithClient
31+ | { width : null ; height : null ; clientWidth : null ; clientHeight : null } ;
2932
3033/**
3134 * Instantiate a new ResizeObserver that automatically get's disposed on cleanup.
@@ -139,7 +142,12 @@ export function createWindowSize(): Readonly<Size> {
139142export const useWindowSize : typeof createWindowSize =
140143 /*#__PURE__*/ createHydratableSingletonRoot ( createWindowSize ) ;
141144
142- const ELEMENT_SIZE_FALLBACK = { width : null , height : null } as const satisfies NullableSize ;
145+ const ELEMENT_SIZE_FALLBACK = {
146+ width : null ,
147+ height : null ,
148+ clientWidth : null ,
149+ clientHeight : null ,
150+ } as const satisfies NullableSize ;
143151
144152/**
145153 * @param target html element
@@ -150,7 +158,8 @@ export function getElementSize(target: Element | false | undefined | null): Null
150158 return { ...ELEMENT_SIZE_FALLBACK } ;
151159 }
152160 const { width, height } = target . getBoundingClientRect ( ) ;
153- return { width, height } ;
161+ const { clientWidth, clientHeight } = target ;
162+ return { width, height, clientWidth, clientHeight } ;
154163}
155164
156165/**
@@ -163,7 +172,7 @@ export function getElementSize(target: Element | false | undefined | null): Null
163172 * console.log(size.width, size.height)
164173 * })
165174 */
166- export function createElementSize ( target : Element ) : Readonly < Size > ;
175+ export function createElementSize ( target : Element ) : SizeWithClient ;
167176export function createElementSize (
168177 target : Accessor < Element | false | undefined | null > ,
169178) : Readonly < NullableSize > ;
0 commit comments