rniemeyer / knockout-sortable

A Knockout.js binding to connect observableArrays with jQuery UI sortable functionality
MIT License
547 stars 128 forks source link

Implement optional "strategyMove" behaviour that moves rather than reinserts DOM nodes #160

Closed JD-Robbs closed 8 years ago

JD-Robbs commented 8 years ago

As per #83, this implements the option strategyMove which can either be set globally via ko.bindingHandlers.sortable.strategyMove = true or by passing strategyMove: true into the sortable binding like sortable: { strategyMove: true }.

strategyMove is the best I could come-up with. :smile:

I'm not quite sure if the additions to package.json and bower.json are desired, but I just went ahead and did them since npm was complaining about the missing license field anyway.

This is a 99% re-use of what @Crunc already did in #83 - this PR is merely making it optional to get the ball rolling.

What's potentially missing is an addition to the specs, but I'm a tad lost as far as simulating draggable/sortable is concerned.

Finally, one thing I realised is that, if I see this correctly, afterAdd won't fire when strategyMove is employed since, well, it won't be added anymore - that may need to be mentioned in the docs.

P.S.: I don't know why my indenting keeps exploding like that.

rniemeyer commented 8 years ago

@JD-Robbs Thanks- I'll work towards getting this in.

rniemeyer commented 8 years ago

Sorry for the delay. Thanks for putting together this PR. It is merged and available in v0.13.0.