One-com / knockout-dragdrop

A drag and drop binding for Knockout.
BSD 3-Clause "New" or "Revised" License
85 stars 29 forks source link

Dragging/dropping is laggy on slower computers when using the dragOver event #39

Open DBosley opened 8 years ago

DBosley commented 8 years ago

If a function is called on the 'dragOver' event, depending on the function's complexity, it can make slower computers very laggy while dragging.

If there was a way to reduce the speed at which this executes, that would help a lot for performance.

papandreou commented 8 years ago

You mean some kind of throttling/debouncing of the function itself? Maybe something like https://remysharp.com/2010/07/21/throttling-function-calls could be used so we wouldn't need to build it into knockout-dragdrop?

DBosley commented 8 years ago

I was able to use underscore.js's _.throttle method to get the performance increased. This had some side effects (like if you let go before it would let the 'dragOver' event function execute) but they were pretty simple to resolve. It all works fantastically now, but built in throttling might be a good idea to keep in mind for feature enhancements. Especially if you could guarantee the first execution of the function call.