Jexordexan / vue-slicksort

A set of vue mixins to turn any list into an animated, touch-friendly, sortable list ✌️
http://vue-slicksort.netlify.app
Other
1.48k stars 157 forks source link

Standalone Slicksort component #4

Closed Jexordexan closed 6 years ago

Jexordexan commented 6 years ago

This could behave similarly to the <draggable> component in vuedraggable Where there is one component with a slot for it's children, which have been iterated using v-for.

eyy commented 6 years ago

Another option is to export two components, matching the two mixins. That's what I'm using:

import { ContainerMixin, ElementMixin } from 'vue-slicksort'

const SortableList = {
  mixins: [ ContainerMixin ],
  template: '<div><slot /></div>'
}

const SortableItem = {
  mixins: [ ElementMixin ],
  template: '<div><slot /></div>'
}
ghost commented 6 years ago

@eyy how do you pass options. For example useDragHandle="true".

eyy commented 6 years ago

It's a mixin, the options are passed automatically:

<sortable-list
      v-model="here"
      lockAxis="y"
      :useDragHandle="true"
    >
      <sortable-item
        v-for="(doc, index) in here"
        :index="index"
        :key="doc._id"
        class="box"
      >
// etc.
ghost commented 6 years ago

@eyy Thank you. These should be on docs.

ghost commented 6 years ago

@eyy BTW. The correct usage should be :use-drag-handle="true"

eyy commented 6 years ago

Perhaps these minimal components can be included in the library?

Jexordexan commented 6 years ago

My hesitation about including those is that at some point I want a singular component to do everything kind of like vue-draggable. I dont want people to be confused about which component to use, and when.

eyy commented 6 years ago

I think it's clearer that there are two components; The right naming, and a simple example in the README file, can go a long way.

Jexordexan commented 6 years ago

Hmm, okay! Thanks for your input :) I guess two components isn't terrible and it doesn't require much more code. If you could make a PR and prioritize render functions, that'd be great!

eyy commented 6 years ago

:) Will do. What do you mean by prioritize render functions?

Jexordexan commented 6 years ago

Don't use the template string as it is not compatible with the runtime version of vue. Better to use a render function instead!

More info: https://vuejs.org/v2/guide/installation.html#Runtime-Compiler-vs-Runtime-only