Skip to content

Commit febd051

Browse files
Personal refactor (#1)
* refactor(props): change wrap-tag type * Updated wrap-tag props type to accept component so a vue component can be passed as wrapper * Gist: vue-smooth-dnd uses Container to wrap list of items that are draggable * refactor(render): pass props to wrapping tag * Pass extraProps to container tag so, custom values can be passed to custom container * feat(range): add method to get range * Add method to get current range of shown items, so the dragged item can be indexed based on the start range index and dragged index * build: run prod build for new changes
1 parent 24fe6f4 commit febd051

File tree

4 files changed

+11027
-19
lines changed

4 files changed

+11027
-19
lines changed

dist/index.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@
516516
"default": 'div'
517517
},
518518
wrapTag: {
519-
type: String,
519+
type: [Object, Function],
520520
"default": 'div'
521521
},
522522
wrapClass: {
@@ -699,9 +699,6 @@
699699
}
700700
});
701701

702-
/**
703-
* virtual list default component
704-
*/
705702
var EVENT_TYPE = {
706703
ITEM: 'item_resize',
707704
SLOT: 'slot_resize'
@@ -745,9 +742,20 @@
745742
this.$on(EVENT_TYPE.SLOT, this.onSlotResized);
746743
}
747744
},
748-
// set back offset when awake from keep-alive
749745
activated: function activated() {
746+
// set back offset when awake from keep-alive
750747
this.scrollToOffset(this.virtual.offset);
748+
749+
if (this.pageMode) {
750+
document.addEventListener('scroll', this.onScroll, {
751+
passive: false
752+
});
753+
}
754+
},
755+
deactivated: function deactivated() {
756+
if (this.pageMode) {
757+
document.removeEventListener('scroll', this.onScroll);
758+
}
751759
},
752760
mounted: function mounted() {
753761
// set position
@@ -773,6 +781,10 @@
773781
}
774782
},
775783
methods: {
784+
// get range of shown items
785+
getRange: function getRange() {
786+
return this.range;
787+
},
776788
// get item size by id
777789
getSize: function getSize(id) {
778790
return this.virtual.sizes.get(id);
@@ -1033,6 +1045,7 @@
10331045
attrs: {
10341046
role: 'group'
10351047
},
1048+
props: _objectSpread2({}, this.extraProps),
10361049
style: wrapperStyle
10371050
}, this.getRenderSlots(h)), // footer slot
10381051
footer ? h(Slot, {

0 commit comments

Comments
 (0)