feat(svelte): add selectionOnDrag
This commit is contained in:
@@ -45,6 +45,7 @@
|
|||||||
{edges}
|
{edges}
|
||||||
fitView
|
fitView
|
||||||
selectionMode={SelectionMode.Partial}
|
selectionMode={SelectionMode.Partial}
|
||||||
|
selectionOnDrag
|
||||||
panOnScroll
|
panOnScroll
|
||||||
{panOnDrag}
|
{panOnDrag}
|
||||||
{onMoveStart}
|
{onMoveStart}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
## 0.0.27
|
## 0.0.27
|
||||||
|
|
||||||
|
- add `selectionOnDrag` prop - can be used to create figma-like controls in combination with `panOnDrag={false}` / `panOnDrag={[1, 2]}` + `panOnScroll={true}`
|
||||||
- ⚠️ rename `screenToFlowCoordinate` to `screenToFlowPosition`
|
- ⚠️ rename `screenToFlowCoordinate` to `screenToFlowPosition`
|
||||||
- ⚠️ rename `flowToScreenCoordinate` to `flowToScreenPosition`
|
- ⚠️ rename `flowToScreenCoordinate` to `flowToScreenPosition`
|
||||||
- ⚠️ rename `getTransformForBounds` to `getViewportForBounds` (return `{ x: number, y: number, zoom: number }` instead of `[number, number, number]`)
|
- ⚠️ rename `getTransformForBounds` to `getViewportForBounds` (return `{ x: number, y: number, zoom: number }` instead of `[number, number, number]`)
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
type $$Props = PaneProps;
|
type $$Props = PaneProps;
|
||||||
|
|
||||||
export let panOnDrag: $$Props['panOnDrag'] = undefined;
|
export let panOnDrag: $$Props['panOnDrag'] = undefined;
|
||||||
|
export let selectionOnDrag: $$Props['selectionOnDrag'] = undefined;
|
||||||
|
|
||||||
const dispatch = createEventDispatcher<{
|
const dispatch = createEventDispatcher<{
|
||||||
paneclick: {
|
paneclick: {
|
||||||
@@ -67,9 +68,9 @@
|
|||||||
let containerBounds: DOMRect | null = null;
|
let containerBounds: DOMRect | null = null;
|
||||||
let selectedNodes: Node[] = [];
|
let selectedNodes: Node[] = [];
|
||||||
|
|
||||||
$: isSelecting = $selectionKeyPressed;
|
|
||||||
$: hasActiveSelection = $elementsSelectable && (isSelecting || $selectionRectMode === 'user');
|
|
||||||
$: _panOnDrag = $panActivationKeyPressed || panOnDrag;
|
$: _panOnDrag = $panActivationKeyPressed || panOnDrag;
|
||||||
|
$: isSelecting = $selectionKeyPressed || (selectionOnDrag && _panOnDrag !== true);
|
||||||
|
$: hasActiveSelection = $elementsSelectable && (isSelecting || $selectionRectMode === 'user');
|
||||||
|
|
||||||
function onClick(event: MouseEvent | TouchEvent) {
|
function onClick(event: MouseEvent | TouchEvent) {
|
||||||
dispatch('paneclick', { event });
|
dispatch('paneclick', { event });
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
export type PaneProps = {
|
export type PaneProps = {
|
||||||
panOnDrag?: boolean | number[];
|
panOnDrag?: boolean | number[];
|
||||||
|
selectionOnDrag?: boolean;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -58,6 +58,7 @@
|
|||||||
export let zoomOnPinch: $$Props['zoomOnPinch'] = true;
|
export let zoomOnPinch: $$Props['zoomOnPinch'] = true;
|
||||||
export let panOnScroll: $$Props['panOnScroll'] = false;
|
export let panOnScroll: $$Props['panOnScroll'] = false;
|
||||||
export let panOnDrag: $$Props['panOnDrag'] = true;
|
export let panOnDrag: $$Props['panOnDrag'] = true;
|
||||||
|
export let selectionOnDrag: $$Props['selectionOnDrag'] = undefined;
|
||||||
export let autoPanOnConnect: $$Props['autoPanOnConnect'] = true;
|
export let autoPanOnConnect: $$Props['autoPanOnConnect'] = true;
|
||||||
export let autoPanOnNodeDrag: $$Props['autoPanOnNodeDrag'] = true;
|
export let autoPanOnNodeDrag: $$Props['autoPanOnNodeDrag'] = true;
|
||||||
export let onError: $$Props['onError'] = undefined;
|
export let onError: $$Props['onError'] = undefined;
|
||||||
@@ -179,7 +180,7 @@
|
|||||||
panOnScroll={panOnScroll === undefined ? false : panOnScroll}
|
panOnScroll={panOnScroll === undefined ? false : panOnScroll}
|
||||||
panOnDrag={panOnDrag === undefined ? true : panOnDrag}
|
panOnDrag={panOnDrag === undefined ? true : panOnDrag}
|
||||||
>
|
>
|
||||||
<Pane on:paneclick panOnDrag={panOnDrag === undefined ? true : panOnDrag}>
|
<Pane on:paneclick panOnDrag={panOnDrag === undefined ? true : panOnDrag} {selectionOnDrag}>
|
||||||
<ViewportComponent>
|
<ViewportComponent>
|
||||||
<EdgeRenderer on:edgeclick on:edgecontextmenu {defaultEdgeOptions} />
|
<EdgeRenderer on:edgeclick on:edgecontextmenu {defaultEdgeOptions} />
|
||||||
<ConnectionLine
|
<ConnectionLine
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import type { DOMAttributes } from 'svelte/elements';
|
import type { DOMAttributes } from 'svelte/elements';
|
||||||
import type {
|
import type {
|
||||||
Connection,
|
|
||||||
ConnectionLineType,
|
ConnectionLineType,
|
||||||
NodeOrigin,
|
NodeOrigin,
|
||||||
Viewport,
|
Viewport,
|
||||||
@@ -12,8 +11,6 @@ import type {
|
|||||||
CoordinateExtent,
|
CoordinateExtent,
|
||||||
PanOnScrollMode,
|
PanOnScrollMode,
|
||||||
IsValidConnection,
|
IsValidConnection,
|
||||||
HandleType,
|
|
||||||
NodeBase,
|
|
||||||
OnError,
|
OnError,
|
||||||
ConnectionMode,
|
ConnectionMode,
|
||||||
PanelPosition,
|
PanelPosition,
|
||||||
@@ -66,6 +63,7 @@ export type SvelteFlowProps = DOMAttributes<HTMLDivElement> & {
|
|||||||
zoomOnPinch?: boolean;
|
zoomOnPinch?: boolean;
|
||||||
panOnScroll?: boolean;
|
panOnScroll?: boolean;
|
||||||
panOnDrag?: boolean | number[];
|
panOnDrag?: boolean | number[];
|
||||||
|
selectionOnDrag?: boolean;
|
||||||
onlyRenderVisibleElements?: boolean;
|
onlyRenderVisibleElements?: boolean;
|
||||||
autoPanOnConnect?: boolean;
|
autoPanOnConnect?: boolean;
|
||||||
autoPanOnNodeDrag?: boolean;
|
autoPanOnNodeDrag?: boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user