mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-14 08:36:22 +08:00
refactor: moving connector label to connector view (#11738)
### Changed Moved connector label moving logic from `default-tool` to connector view. #### Other infrastructure changes: - Gfx element view now can handles drag events - Added `context.preventDefault()` support to bypass built-in interactions in extension - Handle the pointer events in element view will bypass the built-in interactions automatically > The built-in interactions include element dragging, click selection, drag-to-scale operations, etc.
This commit is contained in:
@@ -26,6 +26,9 @@ export type EventsHandlerMap = {
|
||||
pointerleave: PointerEventState;
|
||||
pointermove: PointerEventState;
|
||||
pointerup: PointerEventState;
|
||||
dragstart: PointerEventState;
|
||||
dragmove: PointerEventState;
|
||||
dragend: PointerEventState;
|
||||
};
|
||||
|
||||
export type SupportedEvent = keyof EventsHandlerMap;
|
||||
@@ -97,11 +100,24 @@ export class GfxElementModelView<
|
||||
return this.model.containsBound(bounds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches an event to the view.
|
||||
* @param event
|
||||
* @param evt
|
||||
* @returns Whether the event view has any handlers for the event.
|
||||
*/
|
||||
dispatch<K extends keyof EventsHandlerMap>(
|
||||
event: K,
|
||||
evt: EventsHandlerMap[K]
|
||||
) {
|
||||
this._handlers.get(event)?.forEach(callback => callback(evt));
|
||||
const handlers = this._handlers.get(event);
|
||||
|
||||
if (handlers?.length) {
|
||||
handlers.forEach(callback => callback(evt));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
getLineIntersections(start: IVec, end: IVec) {
|
||||
|
||||
Reference in New Issue
Block a user