Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make on-stop aware of the element movement #84

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ The API is declarative. There are four directives (hooked on attributes) that ne
<li>`$helper` is the jqLite/jQuery object of an element that is being dragged around</li>
</ul>
</li>
<li>`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:
<li>`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:
<ul>
<li>`$item` is the item in model which started being moved</li>
<li>`$part` is the part from which the $item originates</li>
<li>`$index` is the index of the $item in $part</li>
<li>`$moved` is true if the item has moved</li>
</ul>
</li>
* `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.
Expand Down
5 changes: 3 additions & 2 deletions src/angular-sortable-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -622,4 +623,4 @@
};
}

})(window, window.angular);
})(window, window.angular);