diff --git a/angular-legacy-sortable.js b/angular-legacy-sortable.js index ba8f868..26bb846 100644 --- a/angular-legacy-sortable.js +++ b/angular-legacy-sortable.js @@ -137,8 +137,6 @@ evt.from.insertBefore(nextSibling, evt.item.nextSibling); } } - - scope.$apply(); } function _destroy() { @@ -155,6 +153,7 @@ watchers = null; sortable = null; nextSibling = null; + removed = null; } @@ -171,11 +170,11 @@ onEnd: function (/**Event*/evt) { _emitEvent(evt, removed); scope.$apply(); + removed = null; }, onAdd: function (/**Event*/evt) { _sync(evt); _emitEvent(evt, removed); - scope.$apply(); }, onUpdate: function (/**Event*/evt) { _sync(evt); diff --git a/e2e/conf.js b/e2e/conf.js index f469e30..ec0f6c1 100644 --- a/e2e/conf.js +++ b/e2e/conf.js @@ -1,4 +1,4 @@ exports.config = { seleniumAddress: 'http://localhost:4444/wd/hub', - specs: ['./basic-drag-drop.e2e.js'], + specs: ['./basic-drag-drop.e2e.js', './nested-drag-drop.e2e.js'], } diff --git a/e2e/nested-drag-drop.e2e.js b/e2e/nested-drag-drop.e2e.js new file mode 100644 index 0000000..f866d68 --- /dev/null +++ b/e2e/nested-drag-drop.e2e.js @@ -0,0 +1,29 @@ +describe('nested drag and drop', () => { + it('should have correct model after moving between lists', () => { + browser.get('http://localhost:8080/nested.html') + browser.executeScript('$("#item2").simulate("drag-n-drop", { dragTarget: $("#item3"), interpolation: {stepWidth: 2, stepDelay: 30}});') + browser.sleep(1000) + element(by.id('main-list')).evaluate('$ctrl.lastDragged.name').then(function(value){ + expect(value).toBe('item2'); + }) + browser.executeScript('$("#item3").simulate("drag-n-drop", { dragTarget: $("#subitem1"), interpolation: {stepWidth: 2, stepDelay: 30}});') + browser.sleep(1000) + element(by.id('main-list')).evaluate('$ctrl.lastDragged.name').then(function(value){ + expect(value).toBe('item3'); + }) + browser.executeScript('$("#item1").simulate("drag-n-drop", { dragTarget: $("#item2"), interpolation: {stepWidth: 2, stepDelay: 30}});') + browser.sleep(1000) + element(by.id('main-list')).evaluate('$ctrl.lastDragged.name').then(function(value){ + expect(value).toBe('item1'); + }) + }) + + it('should allow list with nested list to be dropped in a nested list', () => { + browser.get('http://localhost:8080/nested.html') + 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 =>{ + expect(response).toBeFalsy() + }) + browser.sleep(1000) + }) +}) + \ No newline at end of file diff --git a/example/nested.html b/example/nested.html new file mode 100644 index 0000000..b7612fd --- /dev/null +++ b/example/nested.html @@ -0,0 +1,18 @@ + +
+ + + + + + + + + + + + + +Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: