feat: scrollWidth and scrollHeight in bind:

pull/18245/head
Azuriru 3 weeks ago
parent be8ffeb2a4
commit dda1de1cd4

@ -850,6 +850,8 @@ export interface HTMLAttributes<T extends EventTarget> extends AriaAttributes, D
readonly 'bind:focused'?: boolean | undefined | null;
readonly 'bind:offsetWidth'?: number | undefined | null;
readonly 'bind:offsetHeight'?: number | undefined | null;
readonly 'bind:scrollWidth'?: number | undefined | null;
readonly 'bind:scrollHeight'?: number | undefined | null;
// allow any data- attribute
[key: `data-${string}`]: any;

@ -169,6 +169,8 @@ export function BindDirective(node, context) {
case 'clientHeight':
case 'offsetWidth':
case 'offsetHeight':
case 'scrollWidth':
case 'scrollHeight':
call = b.call('$.bind_element_size', context.state.node, b.literal(node.name), set ?? get);
break;

@ -163,6 +163,14 @@ export const binding_properties = {
omit_in_ssr: true,
invalid_elements: ['svelte:window', 'svelte:document']
},
scrollWidth: {
omit_in_ssr: true,
invalid_elements: ['svelte:window', 'svelte:document']
},
scrollHeight: {
omit_in_ssr: true,
invalid_elements: ['svelte:window', 'svelte:document']
},
contentRect: {
omit_in_ssr: true,
invalid_elements: ['svelte:window', 'svelte:document']

@ -93,7 +93,7 @@ export function bind_resize_observer(element, type, set) {
/**
* @param {HTMLElement} element
* @param {'clientWidth' | 'clientHeight' | 'offsetWidth' | 'offsetHeight'} type
* @param {'clientWidth' | 'clientHeight' | 'offsetWidth' | 'offsetHeight' | 'scrollWidth' | 'scrollHeight'} type
* @param {(size: number) => void} set
*/
export function bind_element_size(element, type, set) {

Loading…
Cancel
Save