Our great sponsors
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
You'll probably still want to attach your 'mousemove' event to document via addEventListener. You can do this in an onMount. Unlike for window, annoyingly svelte currently doesn't have a tag to attach the proper directives (see https://github.com/sveltejs/svelte/issues/3310)
The "best" way I've found (best is subjective since theres a few ways to solve the problem), is to use Svelte Actions for times when whatever it is I'm trying to accomplish is generic enough to be reusable, but not too specific to the point it becomes too complex to manage. Using actions you can emit a custom event with whatever data you want (example could be mouse coordinates). Here's an example of how I used an action along with the Component I used it in.