Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bind the node dimensions to its child's height and width #323

Closed
rohanrajpal opened this issue May 3, 2023 · 3 comments
Closed

Bind the node dimensions to its child's height and width #323

rohanrajpal opened this issue May 3, 2023 · 3 comments

Comments

@rohanrajpal
Copy link
Contributor

In the following example

<script lang="ts">
  import { Node, Svelvet, Anchor } from "svelvet";
  import CustomAnchor from "./CustomAnchor.svelte";

  let itemArr = ["h-40"];
</script>

<div class="h-screen w-full">
  <Svelvet id="my-canvas" TD minimap fitView>
    <Node id="beta" bgColor="green" label="Beta">
      <div class="w-40 h-20" />
      <Anchor id="beta-anchor" />
    </Node>
    <Node
      id="alpha"
      bgColor="red"
      label="Alpha"
      resizable
      position={{ x: 250, y: 100 }}
    >
      <div class="left-0 top-2 absolute">
        <Anchor nodeConnect let:connecting let:hovering let:linked>
          <CustomAnchor {connecting} {hovering} {linked} />
        </Anchor>
      </div>
      <button
        on:click={() => (itemArr = [...itemArr, "h-40"])}
        class="bg-white"
      >
        Increase height
      </button>
      <div>
        {#each itemArr as div, idx}
          <div class="w-40 h-40 bg-white border">
            <button
              class="border"
              on:click={() => {
                itemArr = itemArr.filter((_, i) => i !== idx);
                itemArr = itemArr;
              }}
            >
              Remove height
            </button>
          </div>
        {/each}
      </div>
    </Node>
  </Svelvet>
</div>

Now, if I click on "increase height", you'll notice the height of the node remains the same. It only adapts to the height of the node on the mount & then does not update.

Is this expected behavior? I guess binding the dimensions if the child contents increase/decrease would help.

@briangregoryholmes
Copy link
Contributor

See: #324

@briangregoryholmes
Copy link
Contributor

This is live in v7.0.41

@rohanrajpal
Copy link
Contributor Author

This is live in v7.0.41

Works great! Thank you so much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants