Good day,
I am using Scriptaculous' drag and drop library in my project and I find that if I have more than 4 Droppables on a page that contains many nested elements, the motion of any draggable seem to be bumpy instead of smooth. This happens on IE only.

To see this in action, copy and paste this testcase into a file:

====
<html>
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript" src="scriptaculous.js"></script>
<script type="text/javascript">
function init() {
 new Draggable($("dd"));
 Droppables.add($("pp"), {hoverclass:"over"});
 Droppables.add($("pp2"), {hoverclass:"over"});
 Droppables.add($("pp3"), {hoverclass:"over"});
 Droppables.add($("pp4"), {hoverclass:"over"});
 Droppables.add($("pp5"), {hoverclass:"over"});
}
</script>
<style type="text/css">
div {position:relative}
span {background:silver}
.over {background:gray}
</style>
<body onload="init();">
 <div><div><div><div><div><div><div><div><div><div>
 <p><span id="dd">draggable</span></p>
 <p><span id="pp">drop</span></p>
 <p><span id="pp2">drop</span></p>
 <p><span id="pp3">drop</span></p>
 <p><span id="pp4">drop</span></p>
 <p><span id="pp5">drop</span></p>
 </div></div></div></div></div></div></div></div></div></div>
</body>
</html>
====

After writing some unit tests, I discovered that Droppables was incurred a bottleneck by having to calculate Position.cumulativeOffset for each droppable on each mouseMove. Because the bumpy behavior was unacceptable to our QA staff, I had to write some optimization code.

I achieved this by modifying Droppables.isAffected and Droppables.show to use an implementation of Position.cumulativeOffset that caches the offset values when a flag is set. The flag is set on a per droppable basis and is used to hint to the implementation that the droppable has a static location and therefore its position can be cached.

I was wondering if future Scriptaculous releases would benefit from such an optimization.

Thank you for your time and you have yourself a nice day.


_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to