Giter VIP home page Giter VIP logo

svelte-sortable's Introduction

SVELTE-SORTABLE

A Svelte wrapper component for SortableJS.

Install

npm i -S svelte-sortable or yarn add svelte-sortable

Usage

<script>
    import { Sortable, MultiDrag } from "svelte-sortable"

    // In case multiselection is to be used 
    Sortable.mount(new MultiDrag());

    let items = [
        "foo",
        "bar",
        "baz",
    ]

    function onChange() {
        //`items` are mutated
        console.log(items)
    }

</script>

<Sortable {items}
          let:item={item}
          on:change={onChange}>
    <div>
        {item}
    </div>
</Sortable>

svelte-sortable's People

Contributors

jjagielka avatar plkmarudny avatar progging avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

svelte-sortable's Issues

SvelteKit compatibilty

For some reasons, Sortable is not a valid SSR component :

Trace

Error: <Sortable> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules
    at Module.validate_component (/node_modules/svelte/internal/index.mjs:1748:15)
    at eval (/src/routes/admin/accommodations/[accommodationIdOrNew].svelte:447:31)
    at Object.$$render (/node_modules/svelte/internal/index.mjs:1771:22)
    at Object.default (root.svelte:46:41)
    at eval (/src/routes/admin/[email protected]:140:77)
    at Object.$$render (/node_modules/svelte/internal/index.mjs:1771:22)
    at Object.default (root.svelte:40:39)
    at eval (/src/routes/__layout-reset.svelte:8:41)
    at Object.$$render (/node_modules/svelte/internal/index.mjs:1771:22)
    at root.svelte:38:37

SvelteKit version

in "@sveltejs/kit": "1.0.0-next.405"
"svelte-sortable": "^0.1.0",

Moving between two lists issue

Looks like that moving items between two lists is not really working, as if onMove is missing somehow? Here is the REPL that demonstrates that, moving form the bottom to top changes the order in the top list, moving from the top list to the bottom one leaves some undefined items in the bottom list.

The code is copied to insert some debug messages.

Svelte bind:group looses the dome element position when items are sorted

When I sort class:selected={defaultImg === item.name} this can't figure out the actual element where the class needs to be assing to.

let defaultImg

 <Sortable {items} let:item={item} on:change={onChange}>
    <label class="label" class:selected={defaultImg === item.name} data-name='{item.name}'
           on:dblclick={e => handleRemoveFile(e)}>
      <input type='radio' name="defaultImg" bind:group={defaultImg} value='{item.name}'/>
      <img class="img-fluid" src='{item.thumb}' alt='{item.name}'>
    </label>
  </Sortable>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.