Knockout scrolldown while doing sortable

101 Views Asked by At

Fellows I am using the https://github.com/rniemeyer/knockout-sortable in order to do some custom sortable stuff. But I want at the same time to be able to scoll down when I do these stuff.

Let me explain better:

First Things first I have this ViewModel:

function MagicGirls()
{
  var magicGirls=this;

  magicGirls.girls=ko.observableArray([
                                        new MahouShoujo({name:"Tsukino",surname:"Usagi",order:1,image:"mahou1.png"}),
                                        new MahouShoujo({name:"Takamachi",surname:"Nanoha",order:2,image:"mahou2.png"}),
                                        new MahouShoujo({name:"Testarosa",surname:"Fate",order:3,image:"mahou3.png"}),
                                        ....
                                        new MahouShoujo({name:"Illyasniel",surname:"von Einzbern",order:1000,image:"mahou1000.png"}),
                                      ]);


  magicGirls.sortableCallback=function(args)
  {
   var item=args.item;
   //Change Order here
  };
}

function MahouShoujo(data)
{
  var mahou=this;

  mahou.namae=ko.observable(data.name);
  mahou.surname=ko.observable(data.surname);
  mahou.order=ko.observable(data.order);
  mahou.image=ko.observable(data.image)
  mahou.domId=ko.observable("mahou"+data.order);
}

And I diplay them like this

<div data-bind="sortable:{data:girls,afterMove:sortableCallback,connectClass:false,options:{scroll:true,scrollSensitivity:100}},translateTouchEvents:touch">
<div class="panel panel-primary" data-bind="attr:{id:domId}">
  <div class="panel-heading">
    <h3>
      <span data-bind="text:namae"></span>
      <span data-bind="text:surname"></span>
    </h3>
  </div>
  <div class="panel-body" >
    <img data-bind="attr:{src:image}"/>
  </div>
</div>

Now what I want is when click on the div in order to drag the div that displays a MahouShoujo, to be able rto scrolldown with mousewheel, because I have WAY TOO MANY.

Do you know fellows how to do that? Is there a way to "extend" the knockout sortable in order to be able to use a custom javascript code with the library in order to listen the scrolldown and perform it? Of cource the "scroll:true" I pass is somehow just ingored.

I want the folowing example to be able to use it anytime in another projects too. So I want once solved solution.

0

There are 0 best solutions below