svelte-scrollto-element
svelte-scrollto-element copied to clipboard
TS complains when passing a `string` element
Hello, and thanks for forking svelte-scrollto and updating it.
I'm having some trouble using svelte-scrollto-element with TypeScript. I just followed the examples in the readme. The scrolling works totally fine, no problem there. But TS is not happy:
If I do it the action way (which is the one I prefer):
<a use:scrollto={'#images'}>Images</a>
I get this TS error:
Type '"#images"' has no properties in common with type 'ScrollToElementOptions'.
I guess it is expecting a ScrollToElementOptions object, but I'm passing just a string. Should we update the action to accept a string too?
And if I do it the programmatically way:
<a on:click={() => animateScroll.scrollTo({element: '#images'})}>Images</a>
I get this one:
Type 'string' is not assignable to type 'HTMLElement'.
In this case, I see that ScrollToElementOptions.element expects a HTMLElement, but as per the example I'm passing just a string too. Should we change ScrollToElementOptions.element to expect a string?
Am I not getting something, or should I do it another way?
Hi @rubenvar, this should be fixed in this version:
"svelte-scrollto-element": "^0.8.0-next.1",
Let me know and I will release this to production ;)
Thank you! The second issue, doing it the programmatic way with animateScroll.scrollTo({element: '#images'}) is now fixed.
However the first one still gives the same error...