Code Monkey home page Code Monkey logo

ng-sortable's Introduction

ng-sortable

Angular Library for Drag and Drop, supports Sortable and Draggable. No JQuery UI used. Supports Touch devices.

Release:

Latest release version 1.3.8

This Project needs a maintainer, If you would like to be please contact me - [email protected]

Demo Page:

[Simple] (http://a5hik.github.io/ng-sortable/#/kanban)

[Advanced] (http://a5hik.github.io/ng-sortable/#/sprint)

Demo Includes:

  • Drag between adjacent Lists.
  • Control Drag on Specific Destinations.

Features:

  • Drag both Horizontally and Vertically.
  • Drag and Drop items within a column.
  • Drag and Drop items across columns.
  • Can do Ranking by Sorting and Change Status by Moving.
  • Hooks provided to invoke API's after a particular action.
  • Preventing/Allowing Drop Zone can be determined at run time.
  • Enable/Disable Drag at run time.
  • Drag Boundary can be defined.
  • Clone an item and drop.
  • Allows duplicate items to be dropped from the clones.

Implementation Details:

  • Uses angular/native JS for sortable and draggable. no JQueryUI used.
  • Provides callbacks for drag/drop events.
  • Implementation follows Prototypical scope inheritance.

Directives structure:

The directives are structured like below.

as-sortable                     --> Items list
  as-sortable-item              --> Item to sort/drag
    as-sortable-item-handle     --> Drag Handle

Design details:

  • ng-model is used to bind the sortable list items with the sortable element.
  • as-sortable can be added to the root element.
  • as-sortable-item can be added in item element, and follows ng-repeat.
  • as-sortable-item-handle can be added to the drag handle in item element.
  • All as-sortable, ng-model, as-sortable-item and as-sortable-item-handle are required.
  • the 'no-drag' attribute can be added to an element to prevent dragging inside as-sortable-item-handle. allows you to perform the element specific event but prevent the element being dragged.
  • the drag item handle can listen for custom events as well.
  • Added a Jquery like 'containment' option to the sortable to prevent the drag outside specified bounds.
  • 'containerPositioning' option may be set to 'relative' to accommodate relative positioning on the container or its ancestry. Use this if the draggable item is offset from the mouse cursor while dragging. A common scenario for this is when using bootstrap columns.
  • The 'is-disabled' attribute can be added optionally to as-sortable disable the Drag at runTime.
  • Added a longTouch option to the sortable, setting to true will cause the drag and drop functionality to get activated upon long-touch aka touch-and-hold on touch devices. This maintains the native scroll by dragging functionality on touch devices. Default is set to false.

Placeholder:

  • By default a placeholder element is created using the same tag as the as-sortable-item element
  • CSS styling may be applied via the as-sortable-placeholder class
  • Additional classes may be applied via the additionalPlaceholderClass option provided to the as-sortable item. e.g. in JS: $scope.sortableOptions = { additionalPlaceholderClass: 'some-class' }; in HTML:
   ...
</div>```
- A customized placeholder can be provided by specifying the `placeholder` option provided to the as-sortable item. `placeholder` can be both a template string or a function returning a template string.

#### Dragging element CSS
- CSS styling may be applied via the "as-sortable-dragging" class
- When the "as-sortable-item" is being dragged, the CSS class "as-sortable-dragging" is added to all elements.
e.g.
    in HTML
```<!--not dragging-->````
```<div class="as-sortable-item"></div>````
```<!--when dragging as-sortable-item-->```
```<div class="as-sortable-item as-sortable-dragging"></div>````

    in CSS
    .as-sortable-dragging{
       border: 1px dotted #000 !important;
    }
          

#### Callbacks:

Following callbacks are defined, and should be overridden to perform custom logic.

- callbacks.accept = function (sourceItemHandleScope, destSortableScope, destItemScope) {}; //used to determine drag zone is allowed are not.

###### Parameters:
     sourceItemScope - the scope of the item being dragged.
     destScope - the sortable destination scope, the list.
     destItemScope - the destination item scope, this is an optional Param.(Must check for undefined).

- callbacks.orderChanged = function({type: Object}) // triggered when item order is changed with in the same column.
- callbacks.itemMoved = function({type: Object}) // triggered when an item is moved across columns.
- callbacks.dragStart = function({type: Object}) // triggered on drag start.
- callbacks.dragEnd = function({type: Object}) // triggered on drag end.

##### Parameters:
    Object (event) - structure         
             source:
                  index: original index before move.
                  itemScope: original item scope before move.
                  sortableScope: original sortable list scope.
             dest: index
                  index: index after move.
                  sortableScope: destination sortable scope.  
                  
##### Some Notable Fixes:

- Touch is allowed on only one Item at a time. Tap is prevented on draggable item.
- Pressing 'Esc' key will Cancel the Drag Event, and moves back the Item to it's Original location.
- Right Click on mouse is prevented on draggable Item.
- A child element inside a draggable Item can be made as non draggable.

##### Usage:

Get the binaries of ng-sortable with any of the following ways.

```sh
bower install ng-sortable

Or for yeoman with bower automatic include:

bower install ng-sortable -save

Or bower.json

{
  "dependencies": [..., "ng-sortable: "latest_version eg - "1.1.0" ", ...],
}

Or npm

npm install ng-sortable

Make sure to load the scripts in your html.

<script type="text/javascript" src="dist/ng-sortable.min.js"></script>
<link rel="stylesheet" type="text/css" href="dist/ng-sortable.min.css">

<!-- OPTIONAL: default style -->
<link rel="stylesheet" type="text/css" href="dist/ng-sortable.style.min.css">

And Inject the sortable module as dependency.

angular.module('xyzApp', ['as.sortable', '....']);
Html Structure:

Invoke the Directives using below html structure.

<ul data-as-sortable="board.dragControlListeners" data-ng-model="items">
   <li data-ng-repeat="item in items" data-as-sortable-item>
      <div data-as-sortable-item-handle></div>
   </li>
</ul>

Define your callbacks in the invoking controller.

$scope.dragControlListeners = {
    accept: function (sourceItemHandleScope, destSortableScope) {return boolean}//override to determine drag is allowed or not. default is true.
    itemMoved: function (event) {//Do what you want},
    orderChanged: function(event) {//Do what you want},
    containment: '#board'//optional param.
    clone: true //optional param for clone feature.
    allowDuplicates: false //optional param allows duplicates to be dropped.
};

$scope.dragControlListeners1 = {
        containment: '#board'//optional param.
        allowDuplicates: true //optional param allows duplicates to be dropped.
};

That's all you have to do.

Restrict Moving between Columns:

Define the accept callback. and the implementation is your choice. The itemHandleScope(dragged Item) and sortableScope(destination list) is exposed. Compare the scope Objects there like below., If you have to exactly restrict moving between columns.

accept: function (sourceItemHandleScope, destSortableScope) {
  return sourceItemHandleScope.itemScope.sortableScope.$id === destSortableScope.$id;
}

If you want to restrict only to certain columns say you have 5 columns and you want the drag to be allowed in only 3 columns, then you need to implement your custom logic there., and that too becomes straight forward as you have your scope Objects in hand.

And reversing the condition, allows you to Drag across Columns but not within same Column.

How To Revert Move After Validation Failure:

In case you want the item to be reverted back to its original location after a validation failure You can just do the below. In your itemMoved call back define a 'moveSuccess' and 'moveFailure' callbacks. The move failure Impl here just reverts the moved item to its original location.

itemMoved: function (eventObj) {

var moveSuccess, moveFailure;
      /**
       * Action to perform after move success.
       */
      moveSuccess = function() {};

      /**
       * Action to perform on move failure.
       * remove the item from destination Column.
       * insert the item again in original Column.
       */
      moveFailure = function() {   
           eventObj.dest.sortableScope.removeItem(eventObj.dest.index);
           eventObj.source.itemScope.sortableScope.insertItem(eventObj.source.index, eventObj.source.itemScope.item);
      };
}
Horizontal Sorting:

Horizontal Drag and Drop can be achieved using the same Library. The Column display can be tweaked to have horizontal items and the same can be achieved via some CSS tweaks (like making the column display style to "inline-block"). Added a sample in the demo source (refer plunker.css/js/html).

Plunkr example link: http://a5hik.github.io/ng-sortable/#/horizontal

Scroll page after reaching end of visible area.

Implement dragMove callback and follow #13 (comment)

Enable/Disable Drag at Runtime:

The Drag can be controlled at runtime and you can enable/disable it by setting the "is-disabled" property to a boolean value of either true or false.

<div as-sortable is-disabled="is-disabled-boolean-property">..</div>
Testing:
  • Tested on FireFox, IE 9 and Greater, Chrome and Safari.
  • Ipad, Iphone and Android devices.
Development Environment setup:

Clone the master $ git clone https://github.com/a5hik/ng-sortable.git

or Download from Source Master

Installation:
Development Dependencies (Grunt and Bower):

Install Grunt and Bower. $ sudo npm install -g grunt-cli bower

Install Project dependencies:

Run the following commands from the project root directory.

$ npm install
$ bower install
Commands to run:
$ grunt build - builds the source and generates the min files in dist.
$ grunt serve - runs a local web server on node.js
$ grunt test - runs the tests (WIP).
$ grunt test:continuous - end to end test (WIP).

To access the local server, enter the following URL into your web browser:

http://localhost:9009/demo/
NG Modules Link:

If you use this module you can give it a thumbs up at http://ngmodules.org/modules/ng-sortable.

For Bug report, and feature request File an Issue here: issue.

License

MIT, see LICENSE.

ng-sortable's People

Contributors

a5hik avatar bastienmoulia avatar burtonjc avatar chaddjohnson avatar christiankohler avatar dizel3d avatar gabigrin avatar gastonrobledo avatar isaaclyman avatar jhdrn avatar johankvint avatar luispalomo avatar maciej-trebacz avatar mariocasciaro avatar marius-bughiu avatar mbing avatar msieurtoph avatar oori avatar pcan avatar rickmugridge avatar robjacobs avatar steve-tapley avatar tashamc avatar wylieconlon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ng-sortable's Issues

Revert option not working

It would be awesome, if we have an option for "revert" in case we validate the move and it fails.
I am not sure whether the option is already there. I will put a placeholder issue item here.

Thanks in advance.

Copying list items from other list but should create new scope or watch

I have this case where I am using a main list with subitems and when you click a main item you get its subitems who should be draggable.
http://plnkr.co/edit/6s03Gq

It's hard to explain exactly everything, so I made this plunkr and if you follow these steps you will see the problem:

  • Drag the first 'subitem 0_0' down below 'subitem 0_1'
  • Click 'Main item 1'
    • Drag the first item 'subitem 1_1' down to any other place
      --> You will see it not only took this item. but you will also have a subitem from the previous list being attached to it 'subitem 0_0'.

Locating the touch event

I'm working on integrating hammerjs with your wonderful module, so I can identify whether it's a tap or a drag event on my web app.

Any suggestions where I should start? I've read the code, just not sure how the touchevent is implemented here. From what I understand, $window releases events, and you've hooked that into your module. Is that right? A quick explantation would be exceedingly helpful.

Use with Objects

Is there a way, or can there be a way to use this with an Object as my model, instead of an Array?

Handle scroll when list has fixed height

Hi,

Thanks for the great library. We replaced angular-ui-tree for this one since we didn't need the tree functionality and yours allows to drop on the whole ul element.

However, we've come to a case where we would like to scroll when the dragged element is on the edge of the list (and ul with fixed height). How would you recommend we implement it?

Firefox drag issue

Hi

When using the drag and drop in chrome, it works beautifully, however when in firefox, it seems to misbehave. The issue is - when I click down and start moving, it doesnt seem to invoke the placeholders and shift the images around. When I release the mouse click then it all seems to what is suppose to happen when the mouse is down. I think it has something to do with the 10px check. What I did was take the dragStart(event); out of thevar moveListen = function ... function and it all seems to work in FF now. This is around line 593 in the ng-sortable.js file.

I loose out on the 10px detect but for me that is not an issue. Just thought I would raise it with you.

I am still new to angular too, so my knowledge is very limited, thanks for a great plugin.

Flickering during drag

I am trying to implement your great library in my project.

The problem is:
Sometimes if I drag an element, the preview free space is flickering between two states. It seems your directive is not sure, where to show the drop preview.

Unfortunately I can't reproduce this issue with your examples.
The examples always work fine.

Do you have a idea, what the problem might be? Could something in the CSS cause the problem?

Cannot set up the module

Hello,

I'm following the manual on the home page of the project, however I cannot get it work.
It just displays the empty list and as far as I can see in the developer console, angular not iterating over the object.
When I remove ng-sortable directives (as-sortable/as-sortable-item/as-sortable-item-handle) it works.

What could be a reason of the problem?

Here is the plunk: http://plnkr.co/RTKL2LIhqmHbd6B6ciCA

As far as I can see on the demo page source: it uses the directives without the 'as-' prefix. When I remove the 'as-' prefix, it displays my list. However, sortable functionality does not work.

Click event on Draggable Items

Feature Request : Currently there is no single click on draggable items. If we have a tag inside the draggable items it does not work, could you code to enable quick click for tag items and prolonged click for drag ? Please check in to bower if you make this change. Thanks

Problem with item-handle and isolated scope directives

Hi,
In our code we use a directive to display the item contents. However, the code as it stands doesnt work for us as the scope of the element clicked is different. I've narrowed it down to the isDraggable function, and attached a fix for this:

                  sourceScope = elementClicked.scope();

                  // old code
                  // if (!sourceScope || !sourceScope.type || sourceScope.type !== 'handle') {
                  //         return false;

                  // look for the handle on the scope or parent scopes
                  isDraggable = false;
                  while (!isDraggable && sourceScope !== undefined) {
                      if (sourceScope.type && sourceScope.type === 'handle') {
                          isDraggable = true;
                      } else {
                          sourceScope = sourceScope.$parent;
                      }
                  }

If you like, I can attach a PR.

Cheers,
Steve

Kindly Requesting Add Column Button

I love this library, but as a noob I am having trouble getting an "Add Column" function that would be similar to the Add Card. Anyone implemented this and could share or could we include it in the demo? Thanks so much in advance!

How to disable vertical drag drop?

I'm trying to disable vertical drag/drop but allow horozontal drag/drop. The following code works except when I try to "undo" the drag before dropping in another column. If I still have the item picked up, and try to put it back to the original column, it doesn't allow the drop in the original column in the original position.

Is there a better way to disable vertical/same column drag/drop without having this issue?

accept: function (draggedItemScope, destListSortableScope) { //override to determine drag is allowed or not. default is true.
                return draggedItemScope.$parent.sortableScope != destListSortableScope; //disable drag for ranking/vertical

info about target droppable (type=='item') in accept callback

Hello,
it would be useful to pass the currently targeted "item" (= the item whose place we can drop the dragged one into) to the accept() callback. Recently that callback is informed only about the dragged handle and the whole "sortable" scope.
This feature could be utilized when eg. handling certain non-moveable items beside moveables.

Or maybe i missed something, in that case please just let me know how to get this extra info in the accept().

I much like this module btw, thanks for it.

How do you stop items being incorrectly selected when being dragged over?

This is more of a question rather than an issue - however:

I like ng-sortable -but it is giving me one problem and that is the incorrect selection of items when a user clicks anywhere on the page and then drags over the drag items.- example below:
image
I notice that your demo page prevents this from happening but looking at the html I can't see how it does it.

Issue using control with Table rows

When I use this with a table there's a couple of issues:

  1. The display: block for sortable-item and sortable-placeholder move all the columns in the table into the first row
  2. Generally the default css is very opinionated and messes with the css I have for the table
  3. It would be nice if there were some logic to detect if the drag and drop is a table then have it set the height of the dragging item dynamically to the drawn height of the original row. Additional you could loop through and dynamically set the table row width to same width of the original row.

Other than that, great angular control!

SEMVER disappointing

Hi guys, we are using this component in version 1.1.1 and now we had a big problem because of bad tagging by SEMVER standards.

We had in bower.json version 1.1.* and with 1.1.2 should be only patches and no braking changes. You did BC with commit: 7331082 with renaming of the directive.

Can you consider to be more exact in semver naming convention in future?

Error in readme

Could you remove the extra quote in the following:

image

The line should be

data-ng-repeat="item in items" data-sortable-item

Also please consider mentioning the style requirement for the top level container: display: inline-block" - only found that out when I looked at plunker.css example.

bower.json has incorrect values

Following values are incorrect:
"main": [
"dist/ng-sortable.js",
"dist/ng-sortable.min.js",
"dist/ng-sortable.min.css"
],

Reason:
I use grunt wiredep module and mentioned settings used for dependencies infection. As a result my result index looks like:
...
bower:css
link rel="stylesheet" href="bower_components/angular-toastr/dist/angular-toastr.css"
link rel="stylesheet" href="bower_components/angular-datepicker/dist/index.css"
link rel="stylesheet" href="bower_components/ng-sortable/dist/ng-sortable.min.css"
endbower
...
bower:js
...
script src="bower_components/ng-sortable/dist/ng-sortable.js"
script src="bower_components/ng-sortable/dist/ng-sortable.min.js"
...
endbower

As you can see

  1. ng-sortable css dependency contains "min", but another dep. don't have it...
  2. ng-sortable js dependency duplicated

Solution:

Will be good to replace mentioned settings of bower.json to
"main": [
"dist/ng-sortable.js",
"dist/ng-sortable.css"
],

ng-sortable doesn't play nice with orderBy

todos = [{priority: 1, name: 'todo1'}, {priority: 2, name: 'todo2'}]

Let's I want to orderBy priority... but every time I move an element I want the priority to be updated as well. Thus, the filter orderBy: 'priority' will revert the drag and drop changes... Any ideas to persist the new positions?

Support horizontal mode

I use sortable directive to sort images like this:
screenshot-127 0 0 1 9000 2014-07-01 11-31-03
with custom css :

.media-images-sortable {
  margin-left : -10px;
  .sortable-item,
  .sortable-placeholder {
    display     : inline-block;
    width       : 124px;
    height      : 110px;
    margin-left : 10px;
  }
}

but I can't drag & drop other item up to first item
screenshot-127 0 0 1 9000 2014-07-01 11-32-51
Please add support horizontal mode. Thank!

Use with a reverse filter?

Any ideas on how to make this work with a reverse filter like this?

angular.module('app')
  .filter 'reverse', ->
    return (items) ->
      return items.slice().reverse()
<ul data-sortable="board.dragControlListeners" data-ng-model="items">
   <li data-ng-repeat="item in items | reverse" data-sortable-item">
      <div data-sortable-item-handle></div>
   </li>
</ul>

Right now thinking I'd use a separate display array then use the callbacks to reorder the desired array in reverse. Thanks for the module btw! Good stuff!

Trouble using containment

Hi I have multiple sortable lists in my view and want them limit to them self. So I thought just limit them to their wrapping section. But this ends up in a 'Maximum stack size exceeded'. Any hints how I can achieve the functionality of limiting every list?

containment: $ "section:contains('#{generic section text}')"

Draggable offset with containment

I use bootstrap for layout and wish to display a sortable list in a column that is not at the top/left of screen.

When I use containment to restrict the draggable area to this column, the dragged item displays with an offset from the mouse position equal to the offset of the containment area from the top/left of screen.

See plunkr for demonstration: http://plnkr.co/edit/7imDR03AKlotCs4SvyI0?p=preview

If you attempt to drag one of the items you will notice that the item jumps down and to the right of screen by the same distance that the column is from the top/left of screen.

Draggable only works once

In this plunkr when you try to drag the items on the right. You can see it is working fine,
but when you try again, it doesn't change anymore.
http://plnkr.co/edit/6s03Gq

So basically when you drag 'subitem 0_0' below 'subitem 0_1' it will work fine,
But then when you try to drag it up again to its original position, 'subitem 0_1' will stay on top.
(It's the same when you first drag 'subitem 0_1' up and try to drag it down again.)

N.B.There is another issue in this plunkr, but I will address that in another issue. #59

Installation failed with grunt-bower-task

I use grunt-bower-task. When I want to install bower components by grunt bower:install command, I get an error like Fatal error: Unable to find suitable version for angular.

I use AngularJS by version 1.2.16 in my project.

Filtering, sorting, and retaining

I have an app that makes available a pool of previously entered items for use (by drag and drop of course) in each of several sections. There can be a lot of items, so I need to sort, search, and filter the list. I'd also like to filtered selected items for the current section rather than remove from the pool.

  • Thanks.

    directive name is too common

    Hi,
    the directive name "sortable" is too common so it may easy collide with other directives uses the same attribute for their own markup, for example the popular grid component https://github.com/esvit/ng-table also applies the "sortable" attribute for the TD markup and therefore the two great extension doesn't work together.
    A suggestion would be to add some "namespace" before the directive name, eg. a5hik-sortable or something.

    Making a copy of draggable Item

    I would like to move one item from one list to another, but item needs to stay in the original list. How do I do that?

    THX

    Callback accept parameter

    I am trying to do custom logic in a callback.accept function.
    The problem is that I've just got Angulars sourceItemScope and destScope, but not the DOM element of the source and destination. It's not easily possible to get from the scope the element.
    Ugly hack might be this:
    http://stackoverflow.com/questions/23253506/get-dom-element-by-scope-id

    What do I try?
    If I drag an element into a drop area with a specific DOM id, it shouldn't drop really instead do something different.

    $apply() and callbacks like dragEnd

    If I change the model in the dragEnd callback, I always get an error.

    I suppose the problem is the usage of $apply() to start the dragEnd().

    On Stackoverflow I've read that: "you should only use [$apply()] to migrate some data to Angular (integration with other frameworks), but never use this method combined with regular Angular code, as Angular will throw an error then." http://stackoverflow.com/questions/15112584/using-scope-watch-and-scope-apply

    I am not an Angular expert. Maybe you could $broadcast the events?

    Nested sortable

    Hi guys!
    How to make 'ng-sortable' work with nested sortable or disable inner sortable.

    Horizontal mode with multiple rows

    I am using 1.1.0 for horizontal support for a use case similar to #7 but there are multiple rows of boxes. The problem is due to the fact that placeholder height is set slightly larger than it should be in the code and it causes the next row of boxes to shift right.

    When I delete the following line, it works perfectly:

    placeHolder.css('height', $helper.height(scope.itemScope.element) + 'px');

    Is this line really necessary?

    Demo failed to work (problem with Ubuntu/Chromium support?)

    From console:

    TypeError: Cannot read property 'exp' of undefined
        at watchFnToHumanReadableString (<anonymous>:703:19)
        at k.$delegate.__proto__.$watch (<anonymous>:735:28)
        at link (http://localhost:9009/demo/dist/ng-sortable.js:502:17)
        at N (http://localhost:9009/demo/bower_components/angular/angular.min.js:54:372)
        at g (http://localhost:9009/demo/bower_components/angular/angular.min.js:47:256)
        at g (http://localhost:9009/demo/bower_components/angular/angular.min.js:47:273)
        at N (http://localhost:9009/demo/bower_components/angular/angular.min.js:54:313)
        at g (http://localhost:9009/demo/bower_components/angular/angular.min.js:47:256)
        at http://localhost:9009/demo/bower_components/angular/angular.min.js:46:377
        at http://localhost:9009/demo/bower_components/angular/angular.min.js:48:217 <ul class="cards card-list ng-scope ng-pristine ng-valid" as-sortable="kanbanSortOptions" ng-model="column.cards">

    When I am trying to run tests via "grunt test" command:

    grunt test --force
    Running "karma:single" (karma) task
    INFO [karma]: Karma v0.12.24 server started at http://localhost:9876/
    INFO [launcher]: Starting browser Chrome
    INFO [Chromium 37.0.2062 (Ubuntu)]: Connected on socket zuZ_Nyl0-h15MbwXCQ8p with id 37161878
    Chromium 37.0.2062 (Ubuntu): Executed 0 of 0 ERROR (0.006 secs / 0 secs)
    Warning: Task "karma:single" failed. Used --force, continuing.
    
    Done, but with warnings.
    

    Please, what can I try?

    bower.json has incorrect values

    Following values are incorrect:
    "main": [
    "dist/ng-sortable.js",
    "dist/ng-sortable.min.js",
    "dist/ng-sortable.min.css"
    ],

    Reason:
    I use grunt wiredep module and mentioned settings used for dependencies infection. As a result my result index looks like:
    ...

        <link rel="stylesheet" href="bower_components/angular-toastr/dist/angular-toastr.css" />
        <link rel="stylesheet" href="bower_components/angular-datepicker/dist/index.css" />
        <link rel="stylesheet" href="bower_components/ng-sortable/dist/ng-sortable.min.css" />
    

    ...

    ...
    <script src="bower_components/ng-sortable/dist/ng-sortable.js"></script>
    <script src="bower_components/ng-sortable/dist/ng-sortable.min.js"></script>
    ...

    As you can see

    1. ng-sortable css dependency contains "min", but another dep. don't have it...
    2. ng-sortable js dependency duplicated

    Solution:

    Will be good to replace mentioned settings of bower.json to
    "main": [
    "dist/ng-sortable.js",
    "dist/ng-sortable.css"
    ],

    complex object for as-sortable model and getting item's index

    Hello,

    It looks like when attempting to use a complex object for as-sortable model it'll have issue finding index of source/dest items.
    Suppose I want to use the following object as a model:

    $scope.mySortableModel = [
        { id: 'asd', name: 'asd' },
        { id: 'qwe', name: 'qwe' },
        { id: 'zxc', name: 'zxc' },
    ]
    

    ...so:

    <div id="source-inputs" as-sortable="sortOptions" ng-model="mySortableModel">
        ...
    </div>
    

    Drag first item to the second. It'll appear to work. Drag newly first item to the second (again). It won't work because of this line.

    The indexOf function cannot search through complex objects.
    Please consider a solution proposed here.

    Clone feature

    It wourld be nice to be able of cloning the items.

    If you disable the sorting with accepts, and you can clone the items, you transform the list in a draggable one very quickly.

    Use $timeout() instead of safeApply()

    I would like to suggest to use always the Angular service $timeout(), instead of your function safeApply().
    The disadvantages of safeApply:

    • usage of angular variable this.$root.$$phase (variable not documented)
    • it's not possible to do $scope.$apply() inside a callback if really needed

    The advantages of of $timeout():

    • you can use e.g. in the dragEnd() callback another $timeout() to apply some changes

    Maybe I overlooked some problems with $timeout. It's asynchronous and might cause some other problems. At my project I am using $timeout and I haven't got any problems.

    isEnabled property

    It would be helpful to have a option to enable/disable the sortable during runtime.

    <div sortable="someOptions" is-enabled="true">...</div>

    Scrollable and checkbox multiselect

    Is there any way to make column to be scrollable ?

    For example if i have 6 columns, it would be much easier if column can be scrollable so you can have like 5,6 cards and rest you can see when you scroll.
    Then all of them would be visible on the screen

    And check box on side and one for select all, for selecting multiple cards at once?

    And thank you for this! :) You have done really great job!

    Base CSS in dist directory?

    Can you add the un-minified css in the dist directory? This will make it easier to read, match the inclusion of the un-minified javascript and include it in the bower install. Thanks!

    Recommend Projects

    • React photo React

      A declarative, efficient, and flexible JavaScript library for building user interfaces.

    • Vue.js photo Vue.js

      ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

    • Typescript photo Typescript

      TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

    • TensorFlow photo TensorFlow

      An Open Source Machine Learning Framework for Everyone

    • Django photo Django

      The Web framework for perfectionists with deadlines.

    • D3 photo D3

      Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

    Recommend Topics

    • javascript

      JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

    • web

      Some thing interesting about web. New door for the world.

    • server

      A server is a program made to process requests and deliver data to clients.

    • Machine learning

      Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

    • Game

      Some thing interesting about game, make everyone happy.

    Recommend Org

    • Facebook photo Facebook

      We are working to build community through open source technology. NB: members must have two-factor auth.

    • Microsoft photo Microsoft

      Open source projects and samples from Microsoft.

    • Google photo Google

      Google โค๏ธ Open Source for everyone.

    • D3 photo D3

      Data-Driven Documents codes.