jexordexan / vue-slicksort Goto Github PK
View Code? Open in Web Editor NEWA set of vue mixins to turn any list into an animated, touch-friendly, sortable list ✌️
Home Page: http://vue-slicksort.netlify.app
License: Other
A set of vue mixins to turn any list into an animated, touch-friendly, sortable list ✌️
Home Page: http://vue-slicksort.netlify.app
License: Other
I'm randomly getting this error after updating to version 1.1.1.
VM121882 vue-slicksort.umd.js:713
Uncaught TypeError: Cannot read property 'x' of undefined
at VueComponent.transitionHelperIntoPlace (VM121882 vue-slicksort.umd.js:713)
at VueComponent.boundFn [as transitionHelperIntoPlace] (VM121357 vue.esm.js:191)
at VueComponent.handleSortEnd (VM121882 vue-slicksort.umd.js:691)
at boundFn (VM121357 vue.esm.js:191)
It's failing here in the transitionHelperIntoPlace function.
var targetX = -deltaScroll.left;
>>>> if (this.translate.x > 0) {
// Diff against right edge when moving to the right
targetX += newIndexNode.offsetLeft + newIndexNode.offsetWidth - (indexNode.offsetLeft + indexNode.offsetWidth);
} else {
targetX += newIndexNode.offsetLeft - indexNode.offsetLeft;
}
We need testing. Mainly unit testing but e2e testing couldn't hurt for the actual drag and drop interactions.
Hello Jexordexan,
What conditions trigger the slip of the previous or next element when dragging up or dragging down?When my sorting elements are not the same height, it is sometimes difficult to trigger the sorting of the elements. Is there a way to set the sorting of the element by dragging the dragged element up or down by 50px?
thanks.
Basically I'm trying to create something like this rather crude jQuery UI example.
I've looked at the examples, but it seems like they don't allow "blank" items to exist.
Does anyone know of an example that supports this, or have an idea how it can be achieved with this library?
It is 404 page. I guess it is deleted.
This can be nice. A type definition file.
Hello Jexordexan,
Awesome project!
I found out that when you use SASS or SCSS for your markup, that slicksort won't be able to find the right css config. You kinda addressed this issue here:
"Item disappearing when sorting / CSS issues"
But I think this is worth noting.
So a quick example:
Template list:
'<ul class="input-list"><slot /></ul>'
Template item:
'<li class="draggable">{{item}}</li>'
SCSS:
.input-list {
.draggable {
cursor: pointer;
}
}
Now when dragging the newly made <li>
will be in <body>
and won't be able to find .draggable because it's nested.
This isn't really an issue but maybe it's worth telling users.
Greetings Dimitri
Hi, when I use distance props on the mobile device, the item can't move.
I see this code has some problems.
vue-slicksort/src/ContainerMixin.js
Line 101 in 62a6b2b
this._pos = {
x: e.pageX,
y: e.pageY,
};
fix
this._pos = {
x: e.touches ? e.touches[0].pageX : e.pageX,
y: e.touches ? e.touches[0].pageY : e.pageY,
};
//or
this._pos = this.getOffset(e);
As noted by @johnfraney in #9:
in version 0.1.5 that items with the ElementMixin no longer register click events. Maybe the CSS fix is the safer option.
Reverting the earlier commit and replacing with the prefixed css rules is the appropriate fix. I will be adding autoprefixer to the storybook webpack config.
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
.
Can you implement the grid drag like the react sortable's grid drag.
I am using Vue framework , and I have a demand , that is grid layout . It's need drag and drop and sorting ... base image.
I hope your vue-slicksort can reslove my problem as soon as possible. thank you.
I'm new to the Vue ecosystem and what strikes me is the lack of a good "drop component". All half decent solutions seem to be sortable-only, but I'm really looking for a way to also be able to designate a component as a simple drop target. I'm posting this as a request here because I think this is currently the nicest component for dragging in the ecosystem and it would be great if this could turn into a full fledge drag 'n drop solution, where draggable, droppable and sortable could be mixed as needed.
If not exist, this would be very useful.
ForEx.
instance.swap(index, index)
Hello Jexordexan,
I found a problem that when the heights of the sorted elements are not equal, dragging the higher-height elements downwards will cause problems where the position of the lower-height elements cannot be replaced. Fortunately, dragging up will not cause the problem.
For example, https://jexordexan.github.io/vue-slicksort/ Simple list,set the height of item1 to 300px, the height of item2 to be the same, the height of item3 to 300px, and then drag item1 downwards, you will not replace the position of item2 in item1, because item3 first slides up.
Cheers.
I'm tweaking my drag & drop feature for both desktop and mobile users. As part of this I'm currently using the handle only on mobile (where users don't have a lot of room to pan), and disabling the handle usage on larger screens (by setting :use-drag-handle="false"
when the viewport gets bigger).
This works pretty excellently right now. However, I would actually prefer to also use the handle directive also on larger screens: I have some interactive elements in my list items that I would prefer to never trigger the drag. I don't think I can currently do this, as I would have to set :use-drag-handle
always to true
, and then add more v-handles that I actually don't want to use on small screens.
My immediate thought was that if I could simply bind v-handle
to any value I wanted, I would have the control I need to choose exactly which handles I want to be active at any given time. In my case, I would set v-handle="false"
or v-handle="true"
depending on screen size, like I already do with the parent parameter.
There are probably other ways to work around the issue in my case as well, I can provide a deeper explanation and snippets if needed.
[Vue warn]: Injection "manager" not found
found in
---> at src/pages/choose/batchMgr.vue
at src/pages/choose/index.vue
at src/App.vue
[Vue warn]: Missing required prop: "index"
found in
---> at src/pages/choose/batchMgr.vue
at src/pages/choose/index.vue
at src/App.vue
raven.min.js:2 [Vue warn]: Error in mounted hook: "TypeError: Cannot read property 'add' of undefined"
found in
---> at src/pages/choose/batchMgr.vue
at src/pages/choose/index.vue
at src/App.vue
a.(anonymous function)
TypeError: Cannot read property 'add' of undefined(…)
I'm logging this as it is bound to be a popular request.
At this time there are lots of assumptions made about the dragging staying scope only within a single collection.
Draggin elements between collections (and possibly between containers) could take a while to figure out.
This will be a 0.2.x feature
There are two situations here.
1.Use listcontainer(the height is less than window height), useWindowAsScrollContainer=true, the result is view has no scrolling changes,but sorting can happen;
2.The height of SlickList component is auto, useWindowAsScrollContainer=true, so body as scrollContainer, the result is view has no scrolling changes,but sorting can happen;
If body as scrollContainer,the height of SlickList component is auto and useWindowAsScrollContainer=true,trigger body scrolling when dragging to the border of a window,so the user can scroll to a specific location and put it in a specific location.
The example is not descriptive. Others a bit complicated.
Where do you write this?
useDragHandle="true"
Can you provide separate examples?
How can I get this plugin to work with nuxt? Any help would be great!
I have a list of collapsible items and would like to minimize them before sorting starts, due to issues related to #32. Is there something like before-sort event or some other hook I can use? Thanks.
Several links are broken in the README
I currently have something (slightly simplified) like this:
<ul class="sidebar-list">
<sidebar-item
v-for="tag in sortedTags"
:key="tag.id"
:class="{ 'selected': currentTag.id == tag.id }"
>
</sidebar-item>
</ul>
Is there an easy way for me to apply the mixins without breaking each bit into another component? The sidebar-item
component isn't always in a sortable container in this case, but I don't want to have to duplicate the component just to apply the mixin to it, while not applying it to others.
Is custom component allowed in mixin?
Forex:
let SortableItem = { mixins: [ElementMixin], props: ["item"], directives: { handle: HandleDirective }, template: '<question-shell v-bind:question="'What is your name?'" question-type="paragraph" v-bind:question-no="1"></question-shell>', }
The error is thrown after I import vue-slicksort
import { SlickList, SlickItem } from 'vue-slicksort'
In the drag handle example, the drag handle SVG background image isn't appearing in Firefox (58.0.1):
I did some digging and can confirm that the hash in color="#000"
causes this behaviour (thanks to this Stack Overflow answer), and using color="black"
fixes it.
I'll send up a PR with that change!
<div class="root">
<SortableList :useDragHandle="true" lockAxis="y" v-model="moduleList" @input="onInput($event)">
<SortableItem v-for="(item, index) in moduleList" :index="index" :key="item.id" :item="item.name" />
</SortableList>
</div>
</template>```
``` const SortableItem = {
mixins: [ElementMixin],
props: ['item'],
template: `
<li class="list-item list-group-item align-items-center">
{{item}}
<div class="pull-right">
<toggle-button :value="true"
color="#82C7EB"
:sync="true"
:labels="true"/>
</div>
<span class="glyphicon handle pull-right text-info"></span>
</li>
`,
};
How make it draggable only with icon.
I suppose add some element with class .handle? but it doesnt work.
Help pls
Great component, thanks for making it available!
I have a use-case for SlickSort where I would like to limit the range in my collection where and item can be dropped. For example, the user can start dragging element number 15, and they can drop it anywhere in indexes 10-20, but aren't allowed to drop it into indexes 1-10.
I could probably handle this by firing a method on @sort-end, and setting the collection back to the original order if the new order isn't allowed, but it would be nice to give some feedback during the drop that this wouldn't be allowed.
Hi! I was wondering if dragging multiple elements at once was possible?
For instance, the user would select several elements with Cmd
+ click
and then drop them.
Hi I`m trying to use this with table element but when using tbody as a container and tr as element, the list always reset to its original order immediately after mouseup event.
Hi! I'd like to know if it was possible for an element to be at the same time a dropzone and a drag item. This would allow to drop an item into another ;)
It there a way to add dymanically new element to slicksort list after server response, for example after image upload?
I'm trying to remove elements from the list via special buttons, with animations.
I can make either sorting work, or delete animation, but not both.
<SortableList lockAxis="y" :useDragHandle="true" v-model="items">
<transition-group name="list">
<SortableListItem v-for="(item, index) in items" :index="index" :key="item.key"
class="md-elevation-1 list-item">
<md-icon v-handle>reorder</md-icon>
<md-field class="md-layout-item">
<md-input v-model="item.name"></md-input>
</md-field>
<md-button class="md-icon-button" @click="deleteItem(index)">
<md-icon>delete</md-icon>
</md-button>
</SortableListItem>
</transition-group>
</SortableList>
.list-item {
transition: all 1s;
}
.list-enter-active, .list-leave-active {
position: absolute;
}
.list-enter, .list-leave-to {
opacity: 0;
transform: translateX(300px);
}
data: () => ({
items: [{name:'foo', key: 0}, {name:'bar', key: 1}, {name:'baz', key:2}],
}),
methods: {
deleteItem(index) {
this.items.splice(index, 1);
}
},
This shows correct animation for deleting, but when I'm trying to drag one of items, they start jumping around. Removing transition-group
fixes it.
I suspect this has something to do with :key
, but when I'm changing to :key="index"
, it also starts lagging, and it still doesn't work.
Is there anyway we can have without creating a div?
Im using css grid layout, this additional div will mess up the structure.
How can i use v-handle inside mixin component?
Forex:
I pass custom component in mixin.
let SortableItem = {
mixins: [ElementMixin],
props: ["item"],
directives: { handle: HandleDirective },
template: '<question-shell v-bind:question="'What is your name?'" question-type="paragraph" v-bind:question-no="1"></question-shell>', }
This is inside component.
<div class="handle" v-handle>
<div class="icon-alpha size-32"></div>
</div>
How can i use v-hande directive inside another component?
this vue-slicksort program work very well, but how to remove one element form the list?
use @click="delImage" at the element is not working.
Hello Jexordexan,
I have the following error when I prepend new items to a SlickSort list.
TypeError: this.$el.sortableInfo is undefined
The error occurs when the items in the list are disabled and their keys are not equal to their index.
Otherwise it works fine.
Here is a jsFiddle that showcase the error: https://jsfiddle.net/spoutnik/7nqm1L56/
Just prepend a new item and look at the console.
I don't really know why but I'm guessing it's due to how Vue is optimizing list rendering when the key is more closely linked to the item itself.
When you trace the error down, you reach this line https://github.com/Jexordexan/vue-slicksort/blob/master/src/ElementMixin.js#L30
Cheers,
Please, put you awesome plugin to cdnjs.cloudflare.com
along with unpkg.com
Hello, using your drag-and-drop plug-in causes the click event (@click) in the component to fail. Is there any solution?
Please for me example use @sortend, thanks.
Hi! Is it possible to select text inside a drag element?
Hi,
I have a problem while sorting. Dragged element disappears from view. It is inserted just before closing body tag. Is there a way to define sortable container?
when list length great then 200; drag can not work
Having a simple way to add a CSS class to the container when an item is being dragged would be helpful. In my specific use case, I want to disable text selection when dragging is happening (w/CSS's user-select: none
), but keep it enabled when no dragging is happening.
If this is already feasible with the current API, please let me know and I'll close this. Thanks ahead of time.
fiddle link is broken.
In the ContainerMinxin.js
getLockPixelOffset(lockOffset) {
...
if (typeof lockOffset === 'string') {
const match = /^[+-]?\d*(?:.\d*)?(px|%)$/.exec(lockOffset);
if (match !== null) {
throw new Error(lockOffset value should be a number or a string of a number followed by "px" or "%". Given ${lockOffset}
);
}
But in my test, when the lockOffset equal '2px',
match is ["2px", "px", index: 0, input: "2px", groups: undefined]
so match !== null return true,and throw the error tips,which I think is the mistake;
If that is not the mistake,please tell me what is the principle?Thanks
I'm a green hand,how to show v-handle [showHandle]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.