Adds I-prefix to all interfaces
This commit is contained in:
parent
80aaab46f2
commit
8ec5f52872
44 changed files with 1731 additions and 1949 deletions
|
|
@ -134,33 +134,33 @@
|
|||
|
||||
import { IEventBus } from '../types/CalendarTypes';
|
||||
import { PositionUtils } from '../utils/PositionUtils';
|
||||
import { ColumnBounds, ColumnDetectionUtils } from '../utils/ColumnDetectionUtils';
|
||||
import { IColumnBounds, ColumnDetectionUtils } from '../utils/ColumnDetectionUtils';
|
||||
import { SwpEventElement, BaseSwpEventElement } from '../elements/SwpEventElement';
|
||||
import {
|
||||
DragStartEventPayload,
|
||||
DragMoveEventPayload,
|
||||
DragEndEventPayload,
|
||||
DragMouseEnterHeaderEventPayload,
|
||||
DragMouseLeaveHeaderEventPayload,
|
||||
DragMouseEnterColumnEventPayload,
|
||||
DragColumnChangeEventPayload
|
||||
IDragStartEventPayload,
|
||||
IDragMoveEventPayload,
|
||||
IDragEndEventPayload,
|
||||
IDragMouseEnterHeaderEventPayload,
|
||||
IDragMouseLeaveHeaderEventPayload,
|
||||
IDragMouseEnterColumnEventPayload,
|
||||
IDragColumnChangeEventPayload
|
||||
} from '../types/EventTypes';
|
||||
import { MousePosition } from '../types/DragDropTypes';
|
||||
import { IMousePosition } from '../types/DragDropTypes';
|
||||
import { CoreEvents } from '../constants/CoreEvents';
|
||||
|
||||
export class DragDropManager {
|
||||
private eventBus: IEventBus;
|
||||
|
||||
// Mouse tracking with optimized state
|
||||
private mouseDownPosition: MousePosition = { x: 0, y: 0 };
|
||||
private currentMousePosition: MousePosition = { x: 0, y: 0 };
|
||||
private mouseOffset: MousePosition = { x: 0, y: 0 };
|
||||
private mouseDownPosition: IMousePosition = { x: 0, y: 0 };
|
||||
private currentMousePosition: IMousePosition = { x: 0, y: 0 };
|
||||
private mouseOffset: IMousePosition = { x: 0, y: 0 };
|
||||
|
||||
// Drag state
|
||||
private originalElement!: HTMLElement | null;
|
||||
private draggedClone!: HTMLElement | null;
|
||||
private currentColumn: ColumnBounds | null = null;
|
||||
private previousColumn: ColumnBounds | null = null;
|
||||
private currentColumn: IColumnBounds | null = null;
|
||||
private previousColumn: IColumnBounds | null = null;
|
||||
private isDragStarted = false;
|
||||
|
||||
// Movement threshold to distinguish click from drag
|
||||
|
|
@ -176,7 +176,7 @@ export class DragDropManager {
|
|||
private dragAnimationId: number | null = null;
|
||||
private targetY = 0;
|
||||
private currentY = 0;
|
||||
private targetColumn: ColumnBounds | null = null;
|
||||
private targetColumn: IColumnBounds | null = null;
|
||||
private positionUtils: PositionUtils;
|
||||
|
||||
constructor(eventBus: IEventBus, positionUtils: PositionUtils) {
|
||||
|
|
@ -336,7 +336,7 @@ export class DragDropManager {
|
|||
* Try to initialize drag based on movement threshold
|
||||
* Returns true if drag was initialized, false if not enough movement
|
||||
*/
|
||||
private initializeDrag(currentPosition: MousePosition): boolean {
|
||||
private initializeDrag(currentPosition: IMousePosition): boolean {
|
||||
const deltaX = Math.abs(currentPosition.x - this.mouseDownPosition.x);
|
||||
const deltaY = Math.abs(currentPosition.y - this.mouseDownPosition.y);
|
||||
const totalMovement = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
||||
|
|
@ -362,7 +362,7 @@ export class DragDropManager {
|
|||
this.currentColumn = ColumnDetectionUtils.getColumnBounds(currentPosition);
|
||||
this.draggedClone = originalElement.createClone();
|
||||
|
||||
const dragStartPayload: DragStartEventPayload = {
|
||||
const dragStartPayload: IDragStartEventPayload = {
|
||||
originalElement: this.originalElement!,
|
||||
draggedClone: this.draggedClone,
|
||||
mousePosition: this.mouseDownPosition,
|
||||
|
|
@ -375,7 +375,7 @@ export class DragDropManager {
|
|||
}
|
||||
|
||||
|
||||
private continueDrag(currentPosition: MousePosition): void {
|
||||
private continueDrag(currentPosition: IMousePosition): void {
|
||||
|
||||
if (!this.draggedClone!.hasAttribute("data-allday")) {
|
||||
// Calculate raw position from mouse (no snapping)
|
||||
|
|
@ -405,7 +405,7 @@ export class DragDropManager {
|
|||
/**
|
||||
* Detect column change and emit event
|
||||
*/
|
||||
private detectColumnChange(currentPosition: MousePosition): void {
|
||||
private detectColumnChange(currentPosition: IMousePosition): void {
|
||||
const newColumn = ColumnDetectionUtils.getColumnBounds(currentPosition);
|
||||
if (newColumn == null) return;
|
||||
|
||||
|
|
@ -413,7 +413,7 @@ export class DragDropManager {
|
|||
this.previousColumn = this.currentColumn;
|
||||
this.currentColumn = newColumn;
|
||||
|
||||
const dragColumnChangePayload: DragColumnChangeEventPayload = {
|
||||
const dragColumnChangePayload: IDragColumnChangeEventPayload = {
|
||||
originalElement: this.originalElement!,
|
||||
draggedClone: this.draggedClone!,
|
||||
previousColumn: this.previousColumn,
|
||||
|
|
@ -434,7 +434,7 @@ export class DragDropManager {
|
|||
|
||||
// Only emit drag:end if drag was actually started
|
||||
if (this.isDragStarted) {
|
||||
const mousePosition: MousePosition = { x: event.clientX, y: event.clientY };
|
||||
const mousePosition: IMousePosition = { x: event.clientX, y: event.clientY };
|
||||
|
||||
// Snap to grid on mouse up (like ResizeHandleManager)
|
||||
const column = ColumnDetectionUtils.getColumnBounds(mousePosition);
|
||||
|
|
@ -455,7 +455,7 @@ export class DragDropManager {
|
|||
if (!dropTarget)
|
||||
throw "dropTarget is null";
|
||||
|
||||
const dragEndPayload: DragEndEventPayload = {
|
||||
const dragEndPayload: IDragEndEventPayload = {
|
||||
originalElement: this.originalElement,
|
||||
draggedClone: this.draggedClone,
|
||||
mousePosition,
|
||||
|
|
@ -530,7 +530,7 @@ export class DragDropManager {
|
|||
/**
|
||||
* Optimized snap position calculation using PositionUtils
|
||||
*/
|
||||
private calculateSnapPosition(mouseY: number, column: ColumnBounds): number {
|
||||
private calculateSnapPosition(mouseY: number, column: IColumnBounds): number {
|
||||
// Calculate where the event top would be (accounting for mouse offset)
|
||||
const eventTopY = mouseY - this.mouseOffset.y;
|
||||
|
||||
|
|
@ -560,7 +560,7 @@ export class DragDropManager {
|
|||
this.currentY += step;
|
||||
|
||||
// Emit drag:move event with current draggedClone reference
|
||||
const dragMovePayload: DragMoveEventPayload = {
|
||||
const dragMovePayload: IDragMoveEventPayload = {
|
||||
originalElement: this.originalElement!,
|
||||
draggedClone: this.draggedClone, // Always uses current reference
|
||||
mousePosition: this.currentMousePosition, // Use current mouse position!
|
||||
|
|
@ -576,7 +576,7 @@ export class DragDropManager {
|
|||
this.currentY = this.targetY;
|
||||
|
||||
// Emit final position
|
||||
const dragMovePayload: DragMoveEventPayload = {
|
||||
const dragMovePayload: IDragMoveEventPayload = {
|
||||
originalElement: this.originalElement!,
|
||||
draggedClone: this.draggedClone,
|
||||
mousePosition: this.currentMousePosition, // Use current mouse position!
|
||||
|
|
@ -633,7 +633,7 @@ export class DragDropManager {
|
|||
/**
|
||||
* Detect drop target - whether dropped in swp-day-column or swp-day-header
|
||||
*/
|
||||
private detectDropTarget(position: MousePosition): 'swp-day-column' | 'swp-day-header' | null {
|
||||
private detectDropTarget(position: IMousePosition): 'swp-day-column' | 'swp-day-header' | null {
|
||||
|
||||
// Traverse up the DOM tree to find the target container
|
||||
let currentElement = this.draggedClone;
|
||||
|
|
@ -659,13 +659,13 @@ export class DragDropManager {
|
|||
return;
|
||||
}
|
||||
|
||||
const position: MousePosition = { x: event.clientX, y: event.clientY };
|
||||
const position: IMousePosition = { x: event.clientX, y: event.clientY };
|
||||
const targetColumn = ColumnDetectionUtils.getColumnBounds(position);
|
||||
|
||||
if (targetColumn) {
|
||||
const calendarEvent = SwpEventElement.extractCalendarEventFromElement(this.draggedClone);
|
||||
|
||||
const dragMouseEnterPayload: DragMouseEnterHeaderEventPayload = {
|
||||
const dragMouseEnterPayload: IDragMouseEnterHeaderEventPayload = {
|
||||
targetColumn: targetColumn,
|
||||
mousePosition: position,
|
||||
originalElement: this.originalElement,
|
||||
|
|
@ -689,7 +689,7 @@ export class DragDropManager {
|
|||
return;
|
||||
}
|
||||
|
||||
const position: MousePosition = { x: event.clientX, y: event.clientY };
|
||||
const position: IMousePosition = { x: event.clientX, y: event.clientY };
|
||||
const targetColumn = ColumnDetectionUtils.getColumnBounds(position);
|
||||
|
||||
if (!targetColumn) {
|
||||
|
|
@ -699,10 +699,10 @@ export class DragDropManager {
|
|||
// Calculate snapped Y position
|
||||
const snappedY = this.calculateSnapPosition(position.y, targetColumn);
|
||||
|
||||
// Extract CalendarEvent from the dragged clone
|
||||
// Extract ICalendarEvent from the dragged clone
|
||||
const calendarEvent = SwpEventElement.extractCalendarEventFromElement(this.draggedClone);
|
||||
|
||||
const dragMouseEnterPayload: DragMouseEnterColumnEventPayload = {
|
||||
const dragMouseEnterPayload: IDragMouseEnterColumnEventPayload = {
|
||||
targetColumn: targetColumn,
|
||||
mousePosition: position,
|
||||
snappedY: snappedY,
|
||||
|
|
@ -727,14 +727,14 @@ export class DragDropManager {
|
|||
return;
|
||||
}
|
||||
|
||||
const position: MousePosition = { x: event.clientX, y: event.clientY };
|
||||
const position: IMousePosition = { x: event.clientX, y: event.clientY };
|
||||
const targetColumn = ColumnDetectionUtils.getColumnBounds(position);
|
||||
|
||||
if (!targetColumn) {
|
||||
return;
|
||||
}
|
||||
|
||||
const dragMouseLeavePayload: DragMouseLeaveHeaderEventPayload = {
|
||||
const dragMouseLeavePayload: IDragMouseLeaveHeaderEventPayload = {
|
||||
targetDate: targetColumn.date,
|
||||
mousePosition: position,
|
||||
originalElement: this.originalElement,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue