From fb6569beae59b373d4534dc350c78baa3658db96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Maccagnoni-Munch?= Date: Mon, 1 Feb 2016 08:03:26 +0100 Subject: [PATCH 1/3] Make on-stop aware of the element movement $moved will be true if the element has moved --- src/angular-sortable-view.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/angular-sortable-view.js b/src/angular-sortable-view.js index 05694f0..cacfe55 100644 --- a/src/angular-sortable-view.js +++ b/src/angular-sortable-view.js @@ -252,7 +252,8 @@ onStop($scope, { $part: originatingPart.model(originatingPart.scope), $index: index, - $item: originatingPart.model(originatingPart.scope)[index] + $item: originatingPart.model(originatingPart.scope)[index], + $moved: !!$target }); if($target){ @@ -622,4 +623,4 @@ }; } -})(window, window.angular); \ No newline at end of file +})(window, window.angular); From 9156413b874b84047a5b0ef9f900d50cd305a6bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Maccagnoni-Munch?= Date: Mon, 1 Feb 2016 08:04:59 +0100 Subject: [PATCH 2/3] Document $moved in the README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8e1b683..ed4b1a0 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ The API is declarative. There are four directives (hooked on attributes) that ne
  • `$item` is the item in model which started being moved
  • `$part` is the part from which the $item originates
  • `$index` is the index of the $item in $part
  • +
  • `$moved` is true if the item has moved
  • * `sv-part` - this attribute should be placed on an element that is a container for the `ngRepeat`'ed elements. Its value should be the same as the right hand side expression in `ng-repeat` attribute. From f82b599d72cc51ee33864b70a606800310c44006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Maccagnoni-Munch?= Date: Mon, 1 Feb 2016 09:00:10 +0100 Subject: [PATCH 3/3] Document $moved in the README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ed4b1a0..8589cce 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ The API is declarative. There are four directives (hooked on attributes) that ne
  • `$helper` is the jqLite/jQuery object of an element that is being dragged around
  • -
  • `sv-on-stop` - The expression passed as a value of that attribute will be evaluated when a user stops moving an element (drops it). This will be called regardless of the fact whether elements have been reordered or now. Several parameters can be injected there like: `sv-on-stop="baz($item, $part, $index)"` where: +
  • `sv-on-stop` - The expression passed as a value of that attribute will be evaluated when a user stops moving an element (drops it). This will be called regardless of the fact whether elements have been reordered or now. Several parameters can be injected there like: `sv-on-stop="baz($item, $part, $index, $moved)"` where:
    • `$item` is the item in model which started being moved
    • `$part` is the part from which the $item originates