|
1 |
| -# THIS PROJECT NEEDS A MAINTAINER. |
2 |
| - |
3 | 1 | angular-legacy-sortable
|
4 | 2 | -----------------------
|
5 | 3 |
|
6 |
| -Demo: http://jsbin.com/naduvo/1/edit?html,js,output |
| 4 | +Angular 1 module that integrates with Sortable.js |
7 | 5 |
|
8 |
| -```html |
9 |
| -<div ng-app="myApp" ng-controller="demo"> |
10 |
| - <ul ng-sortable> |
11 |
| - <li ng-repeat="item in items">{{item}}</li> |
12 |
| - </ul> |
| 6 | +# Installation |
13 | 7 |
|
14 |
| - <ul ng-sortable="{ group: 'foobar' }"> |
15 |
| - <li ng-repeat="item in foo">{{item}}</li> |
16 |
| - </ul> |
| 8 | +## Install with NPM |
| 9 | + npm install angular-legacy-sortablejs |
17 | 10 |
|
18 |
| - <ul ng-sortable="barConfig"> |
19 |
| - <li ng-repeat="item in bar">{{item}}</li> |
20 |
| - </ul> |
21 |
| -</div> |
22 |
| -``` |
| 11 | +# Examples |
23 | 12 |
|
| 13 | +## Simple Drag and Drop |
| 14 | +``` |
| 15 | +angular.module('exampleApp', []) |
| 16 | +.component('dragAndDropExample', { |
| 17 | + template: `<ul ng-sortable> |
| 18 | + <li ng-repeat="item in ['burgers', 'chips', 'hotdog']"> |
| 19 | + {$ item $} |
| 20 | + </li> |
| 21 | + </ul>`, |
| 22 | +}) |
| 23 | +``` |
24 | 24 |
|
25 |
| -```js |
26 |
| -angular.module('myApp', ['ng-sortable']) |
27 |
| - .controller('demo', ['$scope', function ($scope) { |
28 |
| - $scope.items = ['item 1', 'item 2']; |
29 |
| - $scope.foo = ['foo 1', '..']; |
30 |
| - $scope.bar = ['bar 1', '..']; |
31 |
| - $scope.barConfig = { |
32 |
| - group: 'foobar', |
33 |
| - animation: 150, |
34 |
| - onSort: function (/** ngSortEvent */evt){ |
35 |
| - // @see angular-legacy-sortable.js#L18-L24 |
36 |
| - } |
| 25 | +## Specifying a Config |
| 26 | +You can pass a Config obj to `ng-sortable` and it will pass this onto the created sortable object. The available options can be found [here](https://github.com/RubaXa/Sortable#options) |
| 27 | +``` |
| 28 | +angular.module('exampleApp', []) |
| 29 | +.component('dragAndDropExample', { |
| 30 | + template: `<ul ng-sortable=$ctrl.sortableConf> |
| 31 | + <li ng-repeat="item in ['burgers', 'chips', 'hotdog']"> |
| 32 | + {$ item $} |
| 33 | + </li> |
| 34 | + </ul>`, |
| 35 | + controller: function AppSidebarController() { |
| 36 | + var ctrl = this; |
| 37 | + ctrl.sortableConf = { |
| 38 | + animation: 350, |
| 39 | + chosenClass: 'sortable-chosen', |
| 40 | + forceFallback: true, |
37 | 41 | };
|
38 |
| - }]); |
| 42 | + }, |
| 43 | +}) |
39 | 44 | ```
|
40 | 45 |
|
| 46 | +# Drag handle |
| 47 | +Example showing how use the handle option |
| 48 | +``` |
| 49 | +angular.module('exampleApp', []) |
| 50 | +.component('dragAndDropExample', { |
| 51 | + template: `<ul ng-sortable=$ctrl.sortableConf> |
| 52 | + <li ng-repeat="item in ['burgers', 'chips', 'hotdog']" draggable="false"> |
| 53 | + <span class="grab-handle">Drag Header</span> |
| 54 | + <div>{$ item $}</div> |
| 55 | + </li> |
| 56 | + </ul>`, |
| 57 | + controller: function AppSidebarController() { |
| 58 | + var ctrl = this; |
| 59 | + ctrl.sortableConf = { |
| 60 | + animation: 350, |
| 61 | + chosenClass: 'sortable-chosen', |
| 62 | + handle: '.grab-handle', |
| 63 | + forceFallback: true, |
| 64 | + }; |
| 65 | + }, |
| 66 | +}) |
| 67 | +``` |
0 commit comments