vaheqelyan / svelte-grid

A responsive, draggable and resizable grid layout, for Svelte. [NOT MAINTAINED]
https://svelte-grid.now.sh/
MIT License
970 stars 58 forks source link

Make the resizer a slottable element #62

Closed benwoodward closed 3 years ago

benwoodward commented 3 years ago

Currently my grid items are set up so that they scale when pressed. Because the resizer is inside the svelte-grid source code, I don't have a lot of control over it, and as a result it doesn't scale with the rest of the content in the grid item.

It'd be great if it were possible to pass my own resizer element into the grid via a slot. The existing resizer could be extracted into a component that is exported by svelte-grid so that if I were to use the resizer provided by svelte-grid I just import it from svelte-grid, and add it via slot.

Example:

<script>
import Resizer from 'svelte-grid';
thingIsTrue = false;
</script>

<Grid cols={3} bind:items={items} let:item={item}>
  <div>{item.id}</div>
  <Resizer class:my-custom-class={thingIsTrue} />
</Grid>

<style>
.my-custom-class {
}
</style>

svelte-grid-resizer

vaheqelyan commented 3 years ago
<div class=demo-container>
  <Grid bind:items={items} rowHeight={100} let:item let:dataItem {cols} let:resizePointerDown>
    <div class=demo-widget>
      {dataItem.id}
      {#if item.customResizer}
        <div class=resizer on:pointerdown={resizePointerDown}>
          ☞ Resize me
        </div>
      {/if}
    </div>
  </Grid>
</div>

<!-- { customResizer: true } -->

https://svelte-grid.now.sh/examples/custom-resizer

feel free to reopen