sveltejs / svelte

Cybernetically enhanced web apps
https://svelte.dev
MIT License
78.52k stars 4.12k forks source link

Add bind:scrollWidth & bind:scrollHeight properties #13396

Open nounder opened 2 days ago

nounder commented 2 days ago

Describe the problem

Svelte has this wonderful feature that allows to create binding for {client,offset,content}{Width,Height} and other related properties. However, it does not support scroll{Width,Height}. Binding to those values would be useful for creating carousels, sliders, and other scroll-based components.

https://github.com/sveltejs/svelte/blob/3ee8e0b14c9c6549e293eea498ec0659969df513/packages/svelte/src/compiler/phases/bindings.js#L149-L181

Describe the proposed solution

Add bindings for scrollWidth and scrollHeight for all elements.

Importance

nice to have

nounder commented 2 days ago

This would require contents tracking of target element via MutationObserver or through other svelte means.

Any cues or no-gos? I'd like to implement this feature.