chore(astro): use width/height attrs
This commit is contained in:
@@ -27,7 +27,7 @@ const initialNodes: Node[] = [
|
|||||||
type: 'input',
|
type: 'input',
|
||||||
data: { label: 'Node 1' },
|
data: { label: 'Node 1' },
|
||||||
position: { x: 250, y: 5 },
|
position: { x: 250, y: 5 },
|
||||||
size: nodeSize,
|
...nodeSize,
|
||||||
handles: [
|
handles: [
|
||||||
{
|
{
|
||||||
type: 'source',
|
type: 'source',
|
||||||
@@ -41,7 +41,7 @@ const initialNodes: Node[] = [
|
|||||||
id: '2',
|
id: '2',
|
||||||
data: { label: 'Node 2' },
|
data: { label: 'Node 2' },
|
||||||
position: { x: 100, y: 100 },
|
position: { x: 100, y: 100 },
|
||||||
size: nodeSize,
|
...nodeSize,
|
||||||
handles: [
|
handles: [
|
||||||
{
|
{
|
||||||
type: 'source',
|
type: 'source',
|
||||||
@@ -65,7 +65,7 @@ const initialNodes: Node[] = [
|
|||||||
id: '3',
|
id: '3',
|
||||||
data: { label: 'Node 3' },
|
data: { label: 'Node 3' },
|
||||||
position: { x: 400, y: 100 },
|
position: { x: 400, y: 100 },
|
||||||
size: nodeSize,
|
...nodeSize,
|
||||||
handles: [
|
handles: [
|
||||||
{
|
{
|
||||||
type: 'source',
|
type: 'source',
|
||||||
|
|||||||
@@ -11,10 +11,8 @@
|
|||||||
data: { label: 'Node 0' },
|
data: { label: 'Node 0' },
|
||||||
sourcePosition: Position.Right,
|
sourcePosition: Position.Right,
|
||||||
targetPosition: Position.Left,
|
targetPosition: Position.Left,
|
||||||
size: {
|
width: 100,
|
||||||
width: 100,
|
height: 40,
|
||||||
height: 40,
|
|
||||||
},
|
|
||||||
handles: [
|
handles: [
|
||||||
{ type: 'source', x: 100, y: 20, position: Position.Right },
|
{ type: 'source', x: 100, y: 20, position: Position.Right },
|
||||||
{ type: 'target', x: 0, y: 20, position: Position.Left },
|
{ type: 'target', x: 0, y: 20, position: Position.Left },
|
||||||
@@ -26,10 +24,8 @@
|
|||||||
data: { label: 'A' },
|
data: { label: 'A' },
|
||||||
sourcePosition: Position.Right,
|
sourcePosition: Position.Right,
|
||||||
targetPosition: Position.Left,
|
targetPosition: Position.Left,
|
||||||
size: {
|
width: 100,
|
||||||
width: 100,
|
height: 40,
|
||||||
height: 40,
|
|
||||||
},
|
|
||||||
handles: [
|
handles: [
|
||||||
{ type: 'source', x: 100, y: 20, position: Position.Right },
|
{ type: 'source', x: 100, y: 20, position: Position.Right },
|
||||||
{ type: 'target', x: 0, y: 20, position: Position.Left },
|
{ type: 'target', x: 0, y: 20, position: Position.Left },
|
||||||
@@ -41,10 +37,8 @@
|
|||||||
data: { label: 'B' },
|
data: { label: 'B' },
|
||||||
sourcePosition: Position.Right,
|
sourcePosition: Position.Right,
|
||||||
targetPosition: Position.Left,
|
targetPosition: Position.Left,
|
||||||
size: {
|
width: 100,
|
||||||
width: 100,
|
height: 40,
|
||||||
height: 40,
|
|
||||||
},
|
|
||||||
handles: [
|
handles: [
|
||||||
{ type: 'source', x: 100, y: 20, position: Position.Right },
|
{ type: 'source', x: 100, y: 20, position: Position.Right },
|
||||||
{ type: 'target', x: 0, y: 20, position: Position.Left },
|
{ type: 'target', x: 0, y: 20, position: Position.Left },
|
||||||
@@ -56,10 +50,8 @@
|
|||||||
data: { label: 'C' },
|
data: { label: 'C' },
|
||||||
sourcePosition: Position.Right,
|
sourcePosition: Position.Right,
|
||||||
targetPosition: Position.Left,
|
targetPosition: Position.Left,
|
||||||
size: {
|
width: 100,
|
||||||
width: 100,
|
height: 40,
|
||||||
height: 40,
|
|
||||||
},
|
|
||||||
handles: [
|
handles: [
|
||||||
{ type: 'source', x: 100, y: 20, position: Position.Right },
|
{ type: 'source', x: 100, y: 20, position: Position.Right },
|
||||||
{ type: 'target', x: 0, y: 20, position: Position.Left },
|
{ type: 'target', x: 0, y: 20, position: Position.Left },
|
||||||
|
|||||||
@@ -170,7 +170,9 @@
|
|||||||
style:z-index={zIndex}
|
style:z-index={zIndex}
|
||||||
style:transform="translate({positionOriginX}px, {positionOriginY}px)"
|
style:transform="translate({positionOriginX}px, {positionOriginY}px)"
|
||||||
style:visibility={initialized ? 'visible' : 'hidden'}
|
style:visibility={initialized ? 'visible' : 'hidden'}
|
||||||
style="{style} {width ? `;width=${width}px` : ''} {height ? `;height=${height}px;` : ''}"
|
style:width={width === undefined ? undefined : `${width}px`}
|
||||||
|
style:height={height === undefined ? undefined : `${height}px`}
|
||||||
|
{style}
|
||||||
on:click={onSelectNodeHandler}
|
on:click={onSelectNodeHandler}
|
||||||
on:mouseenter={(event) => dispatch('nodemouseenter', { node, event })}
|
on:mouseenter={(event) => dispatch('nodemouseenter', { node, event })}
|
||||||
on:mouseleave={(event) => dispatch('nodemouseleave', { node, event })}
|
on:mouseleave={(event) => dispatch('nodemouseleave', { node, event })}
|
||||||
|
|||||||
@@ -76,11 +76,7 @@ export const getInitialStore = ({
|
|||||||
let viewport: Viewport = { x: 0, y: 0, zoom: 1 };
|
let viewport: Viewport = { x: 0, y: 0, zoom: 1 };
|
||||||
|
|
||||||
if (fitView && width && height) {
|
if (fitView && width && height) {
|
||||||
const nodesWithDimensions = nextNodes.map((node) => ({
|
const nodesWithDimensions = nextNodes.filter((node) => node.width && node.height);
|
||||||
...node,
|
|
||||||
width: node.size?.width,
|
|
||||||
height: node.size?.height
|
|
||||||
}));
|
|
||||||
const bounds = getNodesBounds(nodesWithDimensions, [0, 0]);
|
const bounds = getNodesBounds(nodesWithDimensions, [0, 0]);
|
||||||
viewport = getViewportForBounds(bounds, width, height, 0.5, 2, 0.1);
|
viewport = getViewportForBounds(bounds, width, height, 0.5, 2, 0.1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user