我需要添加自动滚动功能,这是我在v2之前(遵循this guide之后)的做法。
// Drag and drop with scroll
this.drake = dragula([], {
isContainer: (element:any)=>{
return element.classList.contains('nav-item-title');
}
/*
accepts: function (element, target, source, sibling) {
return !target.parentNode.classList.contains('nav-link');
}
*/
});
this.dragService.add('bag', this.drake);
// Copy drake for the autoScroll function
let drake = this.drake;
this.scroll = autoScroll(
// can also be an array of elements if they're { overflow: auto; max-height: XXpx } containers.
// i.e. [someViewChild.nativeElement]
window,
{
margin: 60,
maxSpeed: 25,
scrollWhenOutside: true,
autoScroll: function () { // don't use () => {} syntax, we want to keep the 'this'
// Only scroll when the pointer is down, and there is a child being dragged.
return this.down && drake.dragging;
}
}
);
但是,似乎this.dragService.add('bag', this.drake);
在v2中不再起作用。添加方法发生了什么?我该如何解决?