我有一个angular2
应用typescript
。我正在使用ng2-dragula来拖放应用程序。
我被要求,检查一个条件,如果条件为假,则还原拖动,我知道here revertOnSpill
revertOnSpill:true
ng2-dragula
可以将元素放回到第一位。
但是,我不知道 onDrop
怎么可能。
我在 constructor() {
dragulaService.drop.subscribe((value) => {
this.onDrop(value.slice(1));
});
dragulaService.setOptions('second-bag', {
removeOnSpill: true
});
}
private onDrop(args) {
bla
bla
bla
if(err.status=="404")
this.dragulaService.removeModel;
// this.dragulaService.cancel; also tried but did not work
}
中对此表示赞赏。这是代码
<div id="toPlay" class="playBox roundedBox" [dragula]="'second-bag'">
<img class="w3-animate-top" [src]="sax_path" alt="sax" id="saxsophone"/>
<img class="w3-animate-top" [src]="drum_path" alt="drum" id="drum"/>
</div>
<div id="scene" [dragula]="'second-bag'">
</div>
这是html代码:
"dependencies": {
"dragula": "^3.7.2"
},
"peerDependencies": {
"@angular/common": "^2.0.0",
"@angular/core": "^2.0.0",
"@angular/compiler": "^2.0.0",
"@angular/forms": "^2.0.0"
},
"devDependencies": {
"angular-cli": "1.0.0-beta.22-1",
"typescript": "2.0.10"
}
Package.json是:
<script>
var x = 0017;
var y = 0x17;
alert("x:" + x);
alert("y:" + y);
</script>
问题是,我不知道如何取消放弃?
答案 0 :(得分:4)
有一个名为boolean moves的属性,它控制iff元素是否可移动
this.dragulaService.setOptions('second-bag', {
moves: (el, container, handle) =>{
if(YourCondition)
//return true;
else
//return false;
}))