Commit graph

62 commits

Author SHA1 Message Date
Janus C. H. Knudsen
82921e0643 Extracts drag hover logic into dedicated manager
Moves event hover handling from DragDropManager to a new DragHoverManager.

This improves separation of concerns and makes the hover logic more modular and reusable. The DragHoverManager is now responsible for tracking when the mouse hovers over events, and it emits events for other parts of the application to react to.

The drag:start event is used to deactivate hover tracking when a drag operation starts.
2025-10-13 23:05:03 +02:00
Janus C. H. Knudsen
78ad5d3bc0 Animates drag cancellation
Improves user experience by animating the dragged element back to its original position when the drag operation is cancelled due to the mouse leaving the grid container.
2025-10-13 22:41:20 +02:00
Janus C. H. Knudsen
1d04f0ce0a Improves drag and drop conversion behavior
Resets scroll state and stops edge scrolling when a drag event converts between all-day and timed events, preventing unexpected scrolling behavior during conversion.
2025-10-13 22:17:17 +02:00
Janus C. H. Knudsen
3fd42f1f9b Improves drag scroll compensation accuracy
Refactors drag scroll compensation to use a direct scroll delta instead of accumulating the scroll.

This improves accuracy and responsiveness during drag operations when the scrollable content is being scrolled. It now updates the target position immediately as the user scrolls.
2025-10-13 21:22:33 +02:00
Janus C. H. Knudsen
b0894629df wip 2025-10-13 21:02:09 +02:00
Janus C. H. Knudsen
9a7a90c124 Improves drag-and-drop scroll compensation.
Enhances drag-and-drop functionality by accurately compensating for scroll during drag operations.
This ensures the dragged element remains correctly positioned relative to the mouse,
even when the user scrolls the content during the drag.

It achieves this by:
- Tracking whether scrolling has occurred during a drag operation.
- Factoring scroll delta into target position calculation.
- Updating targetY/currentY instead of directly manipulating the clone's style.
2025-10-13 20:24:19 +02:00
Janus C. H. Knudsen
dbbd19de13 wip 2025-10-13 18:03:08 +02:00
Janus C. H. Knudsen
d259620371 Refactors edge scroll start detection
Improves edge scroll detection by listening for actual scroll events instead of relying on mouse position.

This change ensures that the 'edgescroll:started' event is only emitted when scrolling has actually begun, preventing false positives and improving the accuracy of scroll compensation. It also removes the unnecessary scroll listener from the DragDropManager, consolidating scroll handling in the EdgeScrollManager.
2025-10-13 17:49:19 +02:00
Janus C. H. Knudsen
faf8b50593 Improves drag and drop with edge scrolling
Enhances the drag and drop experience by integrating edge scrolling,
allowing users to scroll the calendar view while dragging events.

Fixes issues with event positioning during scrolling by compensating
for scroll changes during drag operations. Also, adds mock events
to data.
2025-10-13 17:20:17 +02:00
Janus C. H. Knudsen
a0344c6143 Improves drag event handling and scrolling
Refactors drag and drop event handling for smoother updates.

Tracks the current mouse position during drag operations to improve the accuracy of position updates.

Adjusts edge scrolling behavior.
2025-10-12 23:17:22 +02:00
Janus C. H. Knudsen
e620c919aa Improves drag and drop functionality
Refactors drag and drop to use the original element as the source and introduces edge scrolling.

This change aims to enhance the user experience during drag and drop operations by ensuring the correct element is used as the source, fixing issues, and by automatically scrolling the view when the dragged element reaches the edge of the scrollable area.
2025-10-12 22:00:02 +02:00
Janus C. H. Knudsen
40b19a092c Removes auto-scroll functionality.
Removes the auto-scroll feature from the drag and drop manager.

This simplifies the drag and drop interactions by removing the need to automatically scroll the content area during drag operations. The scroll container, related properties, and auto-scroll logic have been removed.

Also, the mouse enter logic was moved to handleEventMouseEnter function.
2025-10-11 09:54:20 +02:00
Janus C. H. Knudsen
42e28f46bc Refactors drag and drop manager for efficiency.
Streamlines drag and drop logic by removing unnecessary state variables
and simplifying column change handling, enhancing performance
and code maintainability.
2025-10-11 09:19:33 +02:00
Janus C. H. Knudsen
0764437642 Moves drag:move emission to animation loop
Ensures drag:move events are emitted during the animation loop
for smoother and more consistent updates during drag operations.
Removes redundant emission from the main drag handling logic.
2025-10-11 01:38:15 +02:00
Janus C. H. Knudsen
9b073a15b7 Refactors all-day event conversion to timed events
Streamlines the conversion of all-day events to timed events during drag and drop operations. This change improves the event rendering process by ensuring proper handling of element replacement and position updates.

Removes redundant code and simplifies the logic for updating the dragged clone.
2025-10-11 01:30:41 +02:00
Janus C. H. Knudsen
78ca23c07a Enables all-day event conversion on column hover
Allows users to convert all-day events to timed events by dragging them over a day column.

This implementation adds logic to the DragDropManager to detect when an all-day event is dragged over a column.
It then emits a new event, 'drag:mouseenter-column', carrying the event data and target column information.

The event rendering service handles this event.
2025-10-10 16:41:48 +02:00
Janus C. H. Knudsen
5d406201b8 Refactors drag and drop logic
Improves drag and drop initialization and handling by extracting methods for clarity.
This enhances code readability and maintainability.
2025-10-08 23:29:56 +02:00
Janus C. H. Knudsen
ecb1729c28 Enhances event drag and resize functionality
Improves event dragging by tracking the source column and using the updated event data for re-rendering affected columns.

Also, enhances event resizing by updating the event data and re-rendering the column to recalculate stacking/grouping.

Uses snap interval as minimum duration when resizing.
2025-10-08 22:18:06 +02:00
Janus C. H. Knudsen
1e5b3166b2 Improves event resizing with smooth animation
Replaces the previous rough event resizing implementation with a smooth, animated approach.

Uses pointer events for accurate tracking and adds a visual resize handle
for better user interaction.
Also refactors drag and drop to exclude resize handle.
2025-10-08 21:43:02 +02:00
Janus C. H. Knudsen
ce0a9b19eb Improves drag and resize behavior
Prevents drag initiation when clicking on the resize handle of an event.
Reduces event height to prevent overlap with time gridlines.
2025-10-08 19:35:29 +02:00
Janus C. H. Knudsen
75d03fe577 Improves drag and drop position calculation
Refines drag and drop functionality by calculating position relative to the column during drag and snapping to the grid on mouse up, resulting in more precise placement.

Addresses an issue where the dragged element's position was not correctly calculated relative to the target column.
2025-10-08 19:01:35 +02:00
Janus C. H. Knudsen
a8b9767524 Implements smooth drag animation
Implements a smooth drag animation for a more fluid user experience.

Instead of directly snapping to the mouse position, it interpolates
the position over time using `requestAnimationFrame`. This provides
a visually smoother movement during drag operations.
2025-10-08 18:30:03 +02:00
Janus C. H. Knudsen
3145752591 Improves event hover highlighting
Uses CSS classes for event hover highlighting,
instead of directly manipulating the background color.
This allows for more flexible and maintainable styling.

Re-enables resize handle manager.
Removes console logs.
2025-10-08 18:15:00 +02:00
Janus C. H. Knudsen
8b8a1e3127 wip, resize, debugging 2025-10-08 00:58:38 +02:00
Janus C. H. Knudsen
5fae433afb Allows dynamic drag clone replacement
Introduces a polymorphic `createClone` method on base event elements to customize clone generation.
Adds a `replaceClone` delegate to drag event payloads, enabling subscribers to dynamically swap the active dragged clone.
This supports scenarios like converting a standard event clone to an all-day event clone when dragging to the all-day header.
2025-10-04 23:10:09 +02:00
Janus C. H. Knudsen
125cd678a3 Refactors drag header interaction logic
Improves efficiency and reliability of drag-and-drop operations involving calendar headers.

Transitions from continuous polling within `handleMouseMove` to using native `mouseenter` and `mouseleave` events with delegation on `swp-calendar-header` elements. This change ensures more precise and performant detection of header interactions during a drag.

Also enhances the initial event detection logic to correctly identify `SWP-ALLDAY-EVENT` elements when starting a drag.
2025-10-04 21:12:52 +02:00
Janus C. H. Knudsen
420036d939 wwip 2025-10-04 16:20:09 +02:00
Janus C. H. Knudsen
a9d6d14c93 Refactors event element handling with web components
Introduces web components for event elements, separating timed and all-day events into distinct components for better organization and reusability.

This change also simplifies event rendering and drag-and-drop operations by leveraging the properties and lifecycle methods of web components.
2025-10-04 15:35:09 +02:00
Janus C. H. Knudsen
6bbf2d8adb Refactors date handling with DateService
Replaces DateCalculator with DateService for improved date and time operations, including timezone handling.

This change enhances the calendar's accuracy and flexibility in managing dates, especially concerning timezone configurations.
It also corrects a typo in the `allDay` dataset attribute.
2025-10-03 20:50:40 +02:00
Janus C. H. Knudsen
4fea01c76b Improves all-day event drag and drop
Addresses issues with all-day event duration calculation and positioning during drag and drop.

- Uses `differenceInCalendarDays` to correctly calculate event duration across timezone and DST boundaries.
- Preserves the original event time when moving events to a different day.
- Snaps dragged event to the top of the target time slot.
2025-10-03 19:09:44 +02:00
Janus C. H. Knudsen
89e8a3f7b2 wip 2025-10-02 23:11:26 +02:00
Janus C. H. Knudsen
a1e1c5d185 Removes unnecessary destroy methods 2025-10-01 22:38:15 +02:00
Janus C. H. Knudsen
ae3aab5dd0 Improves all-day event layout and drag behavior
Refactors all-day event layout calculation and rendering for improved accuracy and performance.

Improves drag-and-drop behavior for all-day events, ensuring correct event placement and column detection.

Addresses issues with event overflow display and provides a more responsive user experience.
2025-10-01 18:41:28 +02:00
Janus C. H. Knudsen
5417a2b6b1 Improves drag and drop functionality
Refactors drag and drop logic to use the dragged clone consistently, fixing issues with event handling and element manipulation during drag operations.
Also includes a fix where the original element is removed after a drag is completed.
Adds column bounds cache update after drag operations for improved column detection.
2025-09-30 00:13:52 +02:00
Janus C. H. Knudsen
83e01f9cb7 Improves all-day event drag and drop
Refactors all-day event conversion during drag and drop to
use the event payload, improving code clarity and reducing
redundancy.

Removes unnecessary style settings and fixes column detection
logic. Addresses an issue where event removal occurred before
successful placement.
2025-09-29 20:50:52 +02:00
Janus C. H. Knudsen
6ccc071587 Refactors drag and drop column detection
Improves drag and drop functionality by refactoring column detection to use column bounds instead of dates.
This change enhances the accuracy and efficiency of determining the target column during drag operations.
It also removes redundant code and simplifies the logic in both the DragDropManager and AllDayManager.
2025-09-28 13:25:09 +02:00
Janus C. H. Knudsen
4141bffca4 Refactors all-day event layout calculation
Simplifies all-day event rendering by streamlining the layout
calculation and event placement process, using the AllDayLayoutEngine
to determine the grid positions. This removes deprecated methods
and improves overall code clarity.
2025-09-27 15:01:22 +02:00
Janus C. H. Knudsen
9dfd4574d8 Improves drag and drop for timed and all-day events
Refactors drag and drop handling to use a cloned event element,
ensuring correct positioning and styling during drag operations
for both regular timed events and all-day events.

This change streamlines the drag and drop process by:
- Creating a clone of the dragged event at the start of the drag.
- Passing the clone through the drag events.
- Handling all-day events with the AllDayManager
- Handling regular timed events with the EventRendererManager

This resolves issues with event positioning and styling during
drag, especially when moving events across columns or between
all-day and timed sections.
2025-09-26 22:53:49 +02:00
Janus C. H. Knudsen
0553089085 Improves all-day event drag and drop
Refactors all-day event drag and drop handling for improved accuracy and performance.

Introduces a shared `ColumnDetectionUtils` for consistent column detection.

Simplifies all-day conversion during drag, placing events in row 1 and calculating the column from the target date.

Implements differential updates during drag end, updating only changed events for smoother transitions.
2025-09-26 22:11:57 +02:00
Janus C. H. Knudsen
134ee29cb1 Improves drag cancellation behavior
Implements drag cancellation when the mouse leaves the calendar container during a drag operation. This prevents orphaned drag clones and restores the original event's state, enhancing user experience.

All-day events now correctly recalculate their height upon drag cancellation, ensuring accurate rendering after clone removal.

Refactors HeaderManager by removing redundant caching of the calendar header element.

Adds new mock event data for September and October 2025 to expand testing and demonstration scenarios.
2025-09-22 17:51:24 +02:00
Janus C. H. Knudsen
c682c30e23 Improves all-day drag-and-drop conversion
Refactors drag-to-all-day functionality to apply CSS styling and reposition the existing drag clone within the all-day container, rather than creating a new event element.

Centralizes all-day container creation in HeaderManager. Introduces `drag:mouseleave-header` to handle transitions from all-day back to timed events.

Ensures consistent styling and robust cleanup of drag clones for a smoother user experience.
2025-09-21 21:30:51 +02:00
Janus C. H. Knudsen
2cdbc8f1a3 Unifies all-day event element tag
Removes the `swp-allday-event` custom element, using `swp-event` for all-day events instead. All-day events are now distinguished by their parent `swp-allday-container`. Simplifies element management and CSS selectors.
2025-09-21 16:03:34 +02:00
Janus C. H. Knudsen
c7dcfbbaed Improves drag-drop event system with type safety
Introduces dedicated TypeScript interfaces for all drag-and-drop event payloads, enhancing type safety and developer experience.

Centralizes drag event detection and emission within `DragDropManager`. Refactors `AllDayManager`, `HeaderManager`, and `EventRendererManager` to subscribe to these typed events, improving decoupling and clarifying responsibilities.

Resolves known inconsistencies in drag event payloads, especially for all-day event conversions. Adds a comprehensive analysis document (`docs/EventSystem-Analysis.md`) detailing the event system and planned improvements.
2025-09-21 15:48:13 +02:00
Janus C. H. Knudsen
b4f5b29da3 Refactors event drag-drop and cloning logic
Centralizes drag event listener setup in `EventRendererManager` for better separation of concerns.

Introduces factory and cloning methods in `SwpEventElement` to simplify event cloning and data extraction from DOM elements during drag operations.

Enhances `DragDropManager` to pass the actual dragged element for conversion and accurately detect the drop target (day column or header).

Updates `EventRenderer` to expose drag-handling methods publicly, allowing the `EventRendererManager` to delegate event-specific drag operations based on drop target.
2025-09-20 09:40:56 +02:00
Janus C. H. Knudsen
0b7499521e Enables all-day event drag and drop
Implements comprehensive drag and drop for all-day events, allowing movement within the header and conversion to timed events when dragged into the calendar grid.

Optimizes column detection with a cached bounding box strategy, improving performance and accuracy. Refactors event conversion logic and renames related event bus events for clarity.
2025-09-19 00:20:30 +02:00
Janus C. H. Knudsen
f1d04ae12e wip 2025-09-18 19:45:40 +02:00
fb40279009 Refactors header drag interaction to eliminate ghost columns
Updates the `HeaderManager` to utilize `mouseenter` and `mouseleave` events on the calendar header for improved performance and accuracy.
Calculates the target date based on the mouse's X-coordinate within the header.

Removes the need for 'ghost columns' by simplifying the logic. This significantly reduces complexity.
The `AllDayEventRenderer` is modified to reflect this change, omitting ghost column creation.

Updates `DragDropManager` to accommodate the new interaction model.
Various console logs are added for debugging purposes.
2025-09-18 17:55:52 +02:00
Janus Knudsen
b95a516806 Improves drag and drop event handling
Refactors drag and drop logic for better event handling and code clarity.

- Moves drag styling to CSS class for cleaner code.
- Emits a 'drag:convert-from-allday' event to handle the conversion of all-day events back to day events.
- Adds logging for debugging purposes.
2025-09-16 23:09:10 +02:00
Janus Knudsen
7e45293128 Improves drag and drop behavior
Hides the drag clone when moving events to the all-day area and shows it again when the mouse leaves the header to prevent visual inconsistencies.
Ensures only the correct all-day event is removed by specifying the container in the selector.
2025-09-14 00:32:27 +02:00
Janus Knudsen
8f1c32c9f9 Removes dragged all-day event on header mouseleave
Ensures that when dragging an event from the all-day section and the mouse leaves the header, the original all-day event is removed, allowing the cloned event in the day columns to take over seamlessly. This prevents duplicate events from appearing.
2025-09-14 00:12:34 +02:00