Skip to content

Commit f63b6c0

Browse files
committed
Fixes #44
1 parent 36efdec commit f63b6c0

File tree

5 files changed

+83
-4
lines changed

5 files changed

+83
-4
lines changed

angular-legacy-sortable.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@
137137
evt.from.insertBefore(nextSibling, evt.item.nextSibling);
138138
}
139139
}
140-
141-
scope.$apply();
142140
}
143141

144142
function _destroy() {
@@ -175,7 +173,6 @@
175173
onAdd: function (/**Event*/evt) {
176174
_sync(evt);
177175
_emitEvent(evt, removed);
178-
scope.$apply();
179176
},
180177
onUpdate: function (/**Event*/evt) {
181178
_sync(evt);

e2e/conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
exports.config = {
22
seleniumAddress: 'http://localhost:4444/wd/hub',
3-
specs: ['./basic-drag-drop.e2e.js'],
3+
specs: ['./basic-drag-drop.e2e.js', './nested-drag-drop.e2e.js'],
44
}

e2e/nested-drag-drop.e2e.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
describe('nested drag and drop', () => {
2+
3+
it('should allow list with nested list to be dropped in a nested list', () => {
4+
browser.get('http://localhost:8080/nested.html')
5+
browser.executeAsyncScript('var done = arguments[0]; window.onerror = done; $("#item2").simulate("drag-n-drop", { dragTarget: $("#subitem1"), interpolation: {stepWidth: 2, stepDelay: 30}}); setTimeout(done, 1000)').then(response =>{
6+
expect(response).toBeFalsy()
7+
})
8+
browser.sleep(1000)
9+
})
10+
})
11+

example/nested.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<html>
2+
<head>
3+
<script src="vendor/jquery.min.js"></script>
4+
<script src="vendor/jquery.simulate.js"></script>
5+
<script src="vendor/jquery.simulate.ext.js"></script>
6+
<script src="vendor/jquery.simulate.drag-n-drop.js"></script>
7+
8+
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
9+
<script src="//cdnjs.cloudflare.com/ajax/libs/Sortable/1.6.0/Sortable.min.js"></script>
10+
<script src="./angular-legacy-sortable.js"></script>
11+
12+
<script src="nestedApp.js"></script>
13+
</head>
14+
15+
<body ng-app="nestedApp">
16+
<nested-drag-and-drop-example></nested-drag-and-drop-example>
17+
</body>
18+
</html>

example/nestedApp.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
angular.module('nestedApp', ['ng-sortable'])
2+
.component('nestedDragAndDropExample', {
3+
template: `<ul id='main-list' ng-sortable="$ctrl.sortableConf">
4+
<li ng-repeat="item in $ctrl.items" >
5+
<span id={{item.name}}> {{ item.name }} </span>
6+
<div ng-if="item.items">
7+
<ul class='nested-list' ng-sortable="$ctrl.nestedSortableConf">
8+
<li ng-repeat="subitem in item.items" >
9+
<span id={{subitem.name}}> {{ subitem.name }} </span>
10+
</li>
11+
</ul>
12+
</div>
13+
</li>
14+
</ul>`,
15+
controller: class ExampleAppController {
16+
constructor() {
17+
var _this = this;
18+
this.items = [{
19+
name: 'item1',
20+
items: [
21+
{
22+
name: 'subitem1',
23+
}
24+
]
25+
},
26+
{
27+
name: 'item2',
28+
items: [
29+
{
30+
name: 'subitem2',
31+
}
32+
]
33+
},
34+
{
35+
name: 'item3'
36+
}]
37+
this.onEnd = function(event) {
38+
_this.lastDragged = event.model;
39+
}
40+
41+
this.sortableConf = {
42+
group: 'all',
43+
forceFallback: true,
44+
onEnd: this.onEnd
45+
}
46+
this.nestedSortableConf = {
47+
group: 'all',
48+
forceFallback: true,
49+
onEnd: this.onEnd
50+
}
51+
}
52+
},
53+
})

0 commit comments

Comments
 (0)