chore(svelte): cleanup handle component
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { getContext, createEventDispatcher } from 'svelte';
|
import { getContext, createEventDispatcher } from 'svelte';
|
||||||
import cc from 'classcat';
|
import cc from 'classcat';
|
||||||
import { Position, type Connection, XYHandle, isMouseEvent } from '@xyflow/system';
|
import { Position, XYHandle, isMouseEvent } from '@xyflow/system';
|
||||||
|
|
||||||
import { useStore } from '$lib/store';
|
import { useStore } from '$lib/store';
|
||||||
import type { HandleComponentProps } from '$lib/types';
|
import type { HandleComponentProps } from '$lib/types';
|
||||||
@@ -43,15 +43,6 @@
|
|||||||
updateConnection
|
updateConnection
|
||||||
} = store;
|
} = store;
|
||||||
|
|
||||||
function dispatchEvent(eventName: string, params?: Connection) {
|
|
||||||
dispatch(eventName, params || { nodeId, handleId, type });
|
|
||||||
}
|
|
||||||
|
|
||||||
function onConnectExtended(params: Connection) {
|
|
||||||
addEdge(params);
|
|
||||||
dispatchEvent('connect', params);
|
|
||||||
}
|
|
||||||
|
|
||||||
function onPointerDown(event: MouseEvent | TouchEvent) {
|
function onPointerDown(event: MouseEvent | TouchEvent) {
|
||||||
const isMouseTriggered = isMouseEvent(event);
|
const isMouseTriggered = isMouseEvent(event);
|
||||||
|
|
||||||
@@ -72,7 +63,10 @@
|
|||||||
panBy,
|
panBy,
|
||||||
onConnect: (connection) => {
|
onConnect: (connection) => {
|
||||||
addEdge(connection);
|
addEdge(connection);
|
||||||
dispatch('connect', { connection: connection });
|
|
||||||
|
// @todo: should we change/ improve the stuff we are passing here?
|
||||||
|
// instead of source/target we could pass fromNodeId, fromHandleId, etc
|
||||||
|
dispatch('connect', { connection });
|
||||||
},
|
},
|
||||||
onConnectStart: (event, startParams) => {
|
onConnectStart: (event, startParams) => {
|
||||||
dispatch('connectstart', {
|
dispatch('connectstart', {
|
||||||
|
|||||||
Reference in New Issue
Block a user