Here you will find a simple application made using Svelte that has an interactive rectangular box that can be dragged across the window. The coordinates of the box are also displayed at the top.
You will find two parts of the code in the source code.
This part has all the variable declarations and the event handlers. The event handlers will detect a mouse click and the motion of the mouse. As the handlers are a child of the box class, they will only be called if a mouse button press is detected inside the box. The mouse movement handler will also assign the position of the cursor to the rectangular box's location.
This part has two objectives, one is to define the box class and its attributes and to display the coordinates. We also assign the mouse events to their respective handler here.
Note: You will need to have Node.js installed.
npm install
npm run dev
npm run build